[
  {
    "trace_id": "1e72bd4d-1ada-45de-8098-5886b7a5c46f",
    "function_name": "prepare_multi_label_classification_response",
    "file_path": "inference/core/models/inference_models_adapters.py",
    "speedup_x": 68464.46,
    "review_quality": "high",
    "pre_optimization_commit": "0804376ceb9a26d63f7e94874b384232350c1fe0",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1345,
    "optimized_function_code_len": 2751,
    "has_patch": false,
    "original_function_preview": "def prepare_multi_label_classification_response(\n    post_processed_predictions: List[MultiLabelClassificationPrediction],\n    image_sizes: List[Tuple[int, int]],\n    class_names: List[str],\n    confi...",
    "optimized_function_only_preview": "def prepare_multi_label_classification_response(\n    post_processed_predictions: List[MultiLabelClassificationPrediction],\n    image_sizes: List[Tuple[int, int]],\n    class_names: List[str],\n    confi..."
  },
  {
    "trace_id": "d5f456ec-4dbc-412c-836e-489db172e66e",
    "function_name": "InferenceModelsDepthAnythingV3Adapter.predict",
    "file_path": "inference/models/depth_anything_v3/depth_anything_v3_inference_models.py",
    "speedup_x": 390.52,
    "review_quality": "high",
    "pre_optimization_commit": "7648e452a70ff1aad09f017a0eb2ea4022b7e177",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1086,
    "optimized_function_code_len": 3403,
    "has_patch": false,
    "original_function_preview": "    def predict(self, inputs: np.ndarray, **kwargs) -> Tuple[dict]:\n        predictions = self._model(inputs)[0]\n        depth_map = predictions.to(torch.float32).cpu().numpy()\n        # Normalize dep...",
    "optimized_function_only_preview": "    def predict(self, inputs: np.ndarray, **kwargs) -> Tuple[dict]:\n        predictions = self._model(inputs)[0]\n        depth_map = predictions.cpu().numpy()\n        # Normalize depth values\n        ..."
  },
  {
    "trace_id": "5eae77af-0ed6-4197-bf2e-f37216264e90",
    "function_name": "measure_memory_for_eviction",
    "file_path": "inference/core/cache/memory.py",
    "speedup_x": 18.13,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 557,
    "optimized_function_code_len": 1823,
    "has_patch": false,
    "original_function_preview": "def measure_memory_for_eviction(detailed: bool = False) -> Optional[MemorySnapshot]:\n    \"\"\"\n    Measure memory state for eviction event.\n\n    Only captures gpu_free before eviction. The after state i...",
    "optimized_function_only_preview": "def measure_memory_for_eviction(detailed: bool = False) -> Optional[MemorySnapshot]:\n    \"\"\"\n    Measure memory state for eviction event.\n\n    Only captures gpu_free before eviction. The after state i..."
  },
  {
    "trace_id": "e1342861-7c06-4eb7-9ac1-354e5c9b35ae",
    "function_name": "DetectionEventLogBlockV1._evict_oldest_video",
    "file_path": "inference/core/workflows/core_steps/analytics/detection_event_log/v1.py",
    "speedup_x": 14.92,
    "review_quality": "medium",
    "pre_optimization_commit": "320928cb553fbad49b455eede555b3a7463de775",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 582,
    "optimized_function_code_len": 1853,
    "has_patch": false,
    "original_function_preview": "    def _evict_oldest_video(self) -> None:\n        \"\"\"Remove the oldest video stream data when MAX_VIDEOS is exceeded.\"\"\"\n        if len(self._event_logs) <= MAX_VIDEOS:\n            return\n\n        # ...",
    "optimized_function_only_preview": "    def _evict_oldest_video(self) -> None:\n        \"\"\"Remove the oldest video stream data when MAX_VIDEOS is exceeded.\"\"\"\n        if len(self._event_logs) <= MAX_VIDEOS:\n            return\n\n        # ..."
  },
  {
    "trace_id": "82993793-3bb9-4fd7-ba69-e855ea486f4d",
    "function_name": "_extract_detail",
    "file_path": "inference/enterprise/workflows/enterprise_blocks/sinks/event_writer/v1.py",
    "speedup_x": 12.46,
    "review_quality": "high",
    "pre_optimization_commit": "ad7d91d0150bee8f45dc26ae83f7c499503c8a4d",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 244,
    "optimized_function_code_len": 1053,
    "has_patch": false,
    "original_function_preview": "def _extract_detail(response: requests.Response) -> str:\n    \"\"\"Try to extract 'detail' from a JSON error response.\"\"\"\n    try:\n        return str(response.json().get(\"detail\", response.text))\n    exc...",
    "optimized_function_only_preview": "def _extract_detail(response: requests.Response) -> str:\n    \"\"\"Try to extract 'detail' from a JSON error response.\"\"\"\n    try:\n        # Quickly determine whether the body could be a JSON object:\n   ..."
  },
  {
    "trace_id": "b286ddf1-eb23-4b9f-a5bf-b2f06950bb7f",
    "function_name": "HaloVisualizationBlockV1.getAnnotator",
    "file_path": "inference/core/workflows/core_steps/visualizations/halo/v2.py",
    "speedup_x": 10.57,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 894,
    "optimized_function_code_len": 1273,
    "has_patch": false,
    "original_function_preview": "    def getAnnotator(\n        self,\n        color_palette: str,\n        palette_size: int,\n        custom_colors: List[str],\n        color_axis: str,\n        opacity: float,\n        kernel_size: int,\n...",
    "optimized_function_only_preview": "    def getAnnotator(\n        self,\n        color_palette: str,\n        palette_size: int,\n        custom_colors: List[str],\n        color_axis: str,\n        opacity: float,\n        kernel_size: int,\n..."
  },
  {
    "trace_id": "7c450cb5-caf6-41b4-809c-0f4dd70b5c8a",
    "function_name": "InferenceModelsDepthAnythingV2Adapter.predict",
    "file_path": "inference/models/depth_anything_v2/depth_anything_v2_inference_models.py",
    "speedup_x": 4.03,
    "review_quality": "high",
    "pre_optimization_commit": "7d46e2fbacd49d1b0d31ef1e4fcd8a6e72927505",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1086,
    "optimized_function_code_len": 2643,
    "has_patch": false,
    "original_function_preview": "    def predict(self, inputs: np.ndarray, **kwargs) -> Tuple[dict]:\n        predictions = self._model(inputs)[0]\n        depth_map = predictions.to(torch.float32).cpu().numpy()\n        # Normalize dep...",
    "optimized_function_only_preview": "    def predict(self, inputs: np.ndarray, **kwargs) -> Tuple[dict]:\n        predictions = self._model(inputs)[0]\n        depth_map = predictions.to(torch.float32).cpu().numpy()\n        # Normalize dep..."
  },
  {
    "trace_id": "9215f881-deaa-4cde-96d1-f35e9d5a37be",
    "function_name": "_should_filter_block",
    "file_path": "inference/core/workflows/core_steps/loader.py",
    "speedup_x": 3.93,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 1731,
    "optimized_function_code_len": 2895,
    "has_patch": false,
    "original_function_preview": "def _should_filter_block(block_class: Type[WorkflowBlock]) -> bool:\n    \"\"\"\n    Check if a block should be filtered out based on configuration.\n    \n    Returns True if the block should be filtered (r...",
    "optimized_function_only_preview": "def _should_filter_block(block_class: Type[WorkflowBlock]) -> bool:\n    \"\"\"\n    Check if a block should be filtered out based on configuration.\n    \n    Returns True if the block should be filtered (r..."
  },
  {
    "trace_id": "2ff1f9c1-0d7b-481a-a5b6-51c00b4eb519",
    "function_name": "DetectionEventLogBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/analytics/detection_event_log/v1.py",
    "speedup_x": 2.4,
    "review_quality": "high",
    "pre_optimization_commit": "10079df8d89971ef2493e294d6d7d99038802b5e",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 5592,
    "optimized_function_code_len": 11752,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        image: WorkflowImageData,\n        detections: sv.Detections,\n        frame_threshold: int,\n        flush_interval: int,\n        stale_frames: int,\n        fallback_f...",
    "optimized_function_only_preview": "    def run(\n        self,\n        image: WorkflowImageData,\n        detections: sv.Detections,\n        frame_threshold: int,\n        flush_interval: int,\n        stale_frames: int,\n        fallback_f..."
  },
  {
    "trace_id": "cc10c2fb-62c2-4ae0-b7f9-9b5a65e4f5a6",
    "function_name": "InferenceModelsClipAdapter.compare",
    "file_path": "inference/models/clip/clip_inference_models.py",
    "speedup_x": 2.37,
    "review_quality": "high",
    "pre_optimization_commit": "7648e452a70ff1aad09f017a0eb2ea4022b7e177",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 2959,
    "optimized_function_code_len": 7340,
    "has_patch": false,
    "original_function_preview": "    def compare(\n        self,\n        subject: Any,\n        prompt: Any,\n        subject_type: str = \"image\",\n        prompt_type: Union[str, List[str], Dict[str, Any]] = \"text\",\n        **kwargs,\n  ...",
    "optimized_function_only_preview": "    def compare(\n        self,\n        subject: Any,\n        prompt: Any,\n        subject_type: str = \"image\",\n        prompt_type: Union[str, List[str], Dict[str, Any]] = \"text\",\n        **kwargs,\n  ..."
  },
  {
    "trace_id": "84cb6370-3148-40ef-b4f4-e436de3160f7",
    "function_name": "clamp_box",
    "file_path": "inference/core/workflows/core_steps/visualizations/text_display/utils.py",
    "speedup_x": 1.8,
    "review_quality": "high",
    "pre_optimization_commit": "a58f6b10343b08a41f49e931daa24e353fabf7a9",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 322,
    "optimized_function_code_len": 526,
    "has_patch": false,
    "original_function_preview": "def clamp_box(\n    box_x: int, box_y: int, box_w: int, box_h: int, img_w: int, img_h: int\n) -> Tuple[int, int]:\n    \"\"\"Clamp box position to image bounds.\"\"\"\n    box_x = 0 if box_w > img_w else max(0,...",
    "optimized_function_only_preview": "def clamp_box(\n    box_x: int, box_y: int, box_w: int, box_h: int, img_w: int, img_h: int\n) -> Tuple[int, int]:\n    \"\"\"Clamp box position to image bounds.\"\"\"\n    if box_w > img_w:\n        box_x = 0\n  ..."
  },
  {
    "trace_id": "4f1c2423-b3a1-43f2-8bb6-c15e9a23bfbe",
    "function_name": "with_route_exceptions_async",
    "file_path": "inference/core/interfaces/http/error_handlers.py",
    "speedup_x": 5.1953170300693055,
    "review_quality": "high",
    "pre_optimization_commit": "607c853289559d1117ee503cf7c703552e1306a7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 16730,
    "optimized_function_code_len": 18991,
    "has_patch": false,
    "original_function_preview": "def with_route_exceptions_async(route):\n    \"\"\"\n    A decorator that wraps a FastAPI route to handle specific exceptions. If an exception\n    is caught, it returns a JSON response with the error messa...",
    "optimized_function_only_preview": "def with_route_exceptions_async(route):\n    \"\"\"\n    A decorator that wraps a FastAPI route to handle specific exceptions. If an exception\n    is caught, it returns a JSON response with the error messa..."
  },
  {
    "trace_id": "1d0ad166-f7b4-47bb-abdd-a70b0ee0d792",
    "function_name": "InferenceModelsPerceptionEncoderAdapter.preprocess",
    "file_path": "inference/models/perception_encoder/perception_encoder_inference_models.py",
    "speedup_x": 1.47,
    "review_quality": "high",
    "pre_optimization_commit": "7648e452a70ff1aad09f017a0eb2ea4022b7e177",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 182,
    "optimized_function_code_len": 2183,
    "has_patch": false,
    "original_function_preview": "    def preprocess(\n        self, image: Any, **kwargs\n    ) -> Tuple[torch.Tensor, PreprocessReturnMetadata]:\n        return self.preproc_image(image), PreprocessReturnMetadata({})\n",
    "optimized_function_only_preview": "    def preprocess(\n        self, image: Any, **kwargs\n    ) -> Tuple[torch.Tensor, PreprocessReturnMetadata]:\n        return load_image_bgr(image), _EMPTY_METADATA"
  },
  {
    "trace_id": "b9e42406-788e-4c48-8367-910fefcc8eae",
    "function_name": "retrieve_selectors_from_union_definition",
    "file_path": "inference/core/workflows/execution_engine/introspection/schema_parser.py",
    "speedup_x": 0.98,
    "review_quality": "high",
    "pre_optimization_commit": "5ec77d6306fd9212f2a8990c421720775f9da64e",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 3146,
    "optimized_function_code_len": 7341,
    "has_patch": false,
    "original_function_preview": "def retrieve_selectors_from_union_definition(\n    property_name: str,\n    property_description: str,\n    union_definition: dict,\n    is_list_element: bool,\n    is_dict_element: bool,\n    property_dime...",
    "optimized_function_only_preview": "def retrieve_selectors_from_union_definition(\n    property_name: str,\n    property_description: str,\n    union_definition: dict,\n    is_list_element: bool,\n    is_dict_element: bool,\n    property_dime..."
  },
  {
    "trace_id": "10df3dd6-e4cf-4942-b158-b6da262b0036",
    "function_name": "MaskAreaMeasurementBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/classical_cv/mask_area_measurement/v1.py",
    "speedup_x": 0.65,
    "review_quality": "high",
    "pre_optimization_commit": "0cfcffe66b48e56a5177c252b38aad0ef3f98c27",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 242,
    "optimized_function_code_len": 1687,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        predictions: sv.Detections,\n    ) -> BlockResult:\n        areas = []\n        for i in range(len(predictions)):\n            areas.append(get_detection_area(prediction...",
    "optimized_function_only_preview": "    def run(\n        self,\n        predictions: sv.Detections,\n    ) -> BlockResult:\n        if predictions.mask is not None:\n            areas = []\n            for i in range(len(predictions)):\n     ..."
  },
  {
    "trace_id": "97d1ea7e-10e0-4723-b296-0090fa39e721",
    "function_name": "_transpose_dict_of_batches_if_needed",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.61,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 1087,
    "optimized_function_code_len": 1351,
    "has_patch": false,
    "original_function_preview": "def _transpose_dict_of_batches_if_needed(\n    value: Dict[str, Any],\n) -> Union[Dict[str, Any], Batch]:\n    \"\"\"Transpose a dict-of-Batches into a Batch-of-dicts.\n\n    Compound dict inputs are resolved...",
    "optimized_function_only_preview": "def _transpose_dict_of_batches_if_needed(\n    value: Dict[str, Any],\n) -> Union[Dict[str, Any], Batch]:\n    \"\"\"Transpose a dict-of-Batches into a Batch-of-dicts.\n\n    Compound dict inputs are resolved..."
  },
  {
    "trace_id": "8c040576-154a-4fcc-b903-dcbf8f6e2ead",
    "function_name": "Qwen3VLBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/models/foundation/qwen3vl/v1.py",
    "speedup_x": 0.45,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 862,
    "optimized_function_code_len": 6069,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n        if s...",
    "optimized_function_only_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n        if s..."
  },
  {
    "trace_id": "9342b3af-dd86-4a27-9d2e-3cae51ca4dbd",
    "function_name": "HeatmapVisualizationBlockV1.getAnnotator",
    "file_path": "inference/core/workflows/core_steps/visualizations/heatmap/v1.py",
    "speedup_x": 0.41,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 946,
    "optimized_function_code_len": 1957,
    "has_patch": false,
    "original_function_preview": "    def getAnnotator(\n        self,\n        position: str,\n        opacity: float,\n        radius: int,\n        kernel_size: int,\n        top_hue: int,\n        low_hue: int,\n    ) -> sv.annotators.bas...",
    "optimized_function_only_preview": "    def getAnnotator(\n        self,\n        position: str,\n        opacity: float,\n        radius: int,\n        kernel_size: int,\n        top_hue: int,\n        low_hue: int,\n    ) -> sv.annotators.bas..."
  },
  {
    "trace_id": "16124b10-e860-4911-ab38-19c7e2992080",
    "function_name": "VideoFrameProcessor.serialize_outputs_sync",
    "file_path": "inference/core/interfaces/webrtc_worker/webrtc.py",
    "speedup_x": 0.37,
    "review_quality": "high",
    "pre_optimization_commit": "5084f39d5f913daa06247d85a5af244b7a835a09",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1347,
    "optimized_function_code_len": 6592,
    "has_patch": false,
    "original_function_preview": "    def serialize_outputs_sync(\n        fields_to_send: List[str],\n        workflow_output: Dict[str, Any],\n        data_output_mode: DataOutputMode,\n    ) -> Tuple[Dict[str, Any], List[str]]:\n       ...",
    "optimized_function_only_preview": "    def serialize_outputs_sync(\n        fields_to_send: List[str],\n        workflow_output: Dict[str, Any],\n        data_output_mode: DataOutputMode,\n    ) -> Tuple[Dict[str, Any], List[str]]:\n       ..."
  },
  {
    "trace_id": "da57dc38-860a-4f59-a834-0b7ccf7d6003",
    "function_name": "YOLO26InstanceSegmentation.predict",
    "file_path": "inference/models/yolo26/yolo26_instance_segmentation.py",
    "speedup_x": 0.26,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 1004,
    "optimized_function_code_len": 814,
    "has_patch": false,
    "original_function_preview": "    def predict(self, img_in: np.ndarray, **kwargs) -> Tuple[np.ndarray, np.ndarray]:\n        \"\"\"Performs inference on the given image using the ONNX session.\n\n        Args:\n            img_in (np.nda...",
    "optimized_function_only_preview": "    def predict(self, img_in: np.ndarray, **kwargs) -> Tuple[np.ndarray, np.ndarray]:\n        \"\"\"Performs inference on the given image using the ONNX session.\n\n        Args:\n            img_in (np.nda..."
  },
  {
    "trace_id": "e8d0f5d4-85ac-4dd4-ac4d-04e0196764b2",
    "function_name": "InferenceModelsObjectDetectionAdapter.postprocess",
    "file_path": "inference/core/models/inference_models_adapters.py",
    "speedup_x": 0.23,
    "review_quality": "high",
    "pre_optimization_commit": "459f2b015b4df2c21d99608520607c01d3460822",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 2228,
    "optimized_function_code_len": 4378,
    "has_patch": false,
    "original_function_preview": "    def postprocess(\n        self,\n        predictions: List[Detections],\n        preprocess_return_metadata: PreprocessingMetadata,\n        **kwargs,\n    ) -> List[ObjectDetectionInferenceResponse]:\n...",
    "optimized_function_only_preview": "    def postprocess(\n        self,\n        predictions: List[Detections],\n        preprocess_return_metadata: PreprocessingMetadata,\n        **kwargs,\n    ) -> List[ObjectDetectionInferenceResponse]:\n..."
  },
  {
    "trace_id": "008c8c5d-317f-4a48-8d15-114823387469",
    "function_name": "serialise_sv_detections",
    "file_path": "inference/core/workflows/core_steps/common/serializers.py",
    "speedup_x": 0.19,
    "review_quality": "high",
    "pre_optimization_commit": "0252251cb80688cc86e37b908dbdde62e01f22c6",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 7444,
    "optimized_function_code_len": 17996,
    "has_patch": false,
    "original_function_preview": "def serialise_sv_detections(detections: sv.Detections) -> dict:\n    serialized_detections = []\n    image_dimensions = None\n    for xyxy, mask, confidence, class_id, tracker_id, data in detections:\n   ...",
    "optimized_function_only_preview": "def serialise_sv_detections(detections: sv.Detections) -> dict:\n    serialized_detections = []\n    image_dimensions = None\n    for xyxy, mask, confidence, class_id, tracker_id, data in detections:\n   ..."
  },
  {
    "trace_id": "a8b29434-aa7f-44be-bf34-904ce73ce6b6",
    "function_name": "CustomCollector._fetch_stream_metrics",
    "file_path": "inference/core/managers/prometheus.py",
    "speedup_x": 0.19,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_events",
    "original_function_code_len": 1205,
    "optimized_function_code_len": 2388,
    "has_patch": false,
    "original_function_preview": "    async def _fetch_stream_metrics(self) -> Dict[str, dict]:\n        pipelines_response = await self.stream_manager_client.list_pipelines()\n        pipeline_ids = pipelines_response.pipelines\n       ...",
    "optimized_function_only_preview": "    async def _fetch_stream_metrics(self) -> Dict[str, dict]:\n        pipelines_response = await self.stream_manager_client.list_pipelines()\n        pipeline_ids = pipelines_response.pipelines\n       ..."
  },
  {
    "trace_id": "4f02367b-64d8-46f0-9750-29947e699ef1",
    "function_name": "Batch.remove_by_indices",
    "file_path": "inference/core/workflows/execution_engine/entities/base.py",
    "speedup_x": 0.2643246529003779,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 606,
    "optimized_function_code_len": 964,
    "has_patch": false,
    "original_function_preview": "    def remove_by_indices(self, indices_to_remove: Set[tuple]) -> \"Batch\":\n        filtered_content = [\n            (\n                element\n                if not isinstance(element, Batch)\n        ...",
    "optimized_function_only_preview": "    def remove_by_indices(self, indices_to_remove: Set[tuple]) -> \"Batch\":\n        filtered_content: List[B] = []\n        filtered_indices: List[Tuple[int, ...]] = []\n\n        for index, element in zi..."
  },
  {
    "trace_id": "3c94634e-3cb0-4cc0-aa69-36b43ae856f9",
    "function_name": "draw_background_with_alpha",
    "file_path": "inference/core/workflows/core_steps/visualizations/text_display/utils.py",
    "speedup_x": 0.18,
    "review_quality": "high",
    "pre_optimization_commit": "82a08ad7e97efa30ce3224d142070ce0ecacd716",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1838,
    "optimized_function_code_len": 3034,
    "has_patch": false,
    "original_function_preview": "def draw_background_with_alpha(\n    img: np.ndarray,\n    pt1: Tuple[int, int],\n    pt2: Tuple[int, int],\n    color: Tuple[int, int, int],\n    alpha: float,\n    border_radius: int,\n) -> None:\n    \"\"\"Dr...",
    "optimized_function_only_preview": "def draw_background_with_alpha(\n    img: np.ndarray,\n    pt1: Tuple[int, int],\n    pt2: Tuple[int, int],\n    color: Tuple[int, int, int],\n    alpha: float,\n    border_radius: int,\n) -> None:\n    \"\"\"Dr..."
  },
  {
    "trace_id": "54ebd6d8-ca87-4901-ae05-719f007536b1",
    "function_name": "get_masks_intersection_for_dimensions",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.22828228810493909,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 648,
    "optimized_function_code_len": 5282,
    "has_patch": false,
    "original_function_preview": "def get_masks_intersection_for_dimensions(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Optional[Set[DynamicBatchIndex]]]:\n    \"\"\"Intersect masks at each dim...",
    "optimized_function_only_preview": "def get_masks_intersection_for_dimensions(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Optional[Set[DynamicBatchIndex]]]:\n    \"\"\"Intersect masks at each dim..."
  },
  {
    "trace_id": "0a2dae36-998a-41b2-aeda-6d4da43017d6",
    "function_name": "get_workflow_cache_file",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 0.17,
    "review_quality": "high",
    "pre_optimization_commit": "7ebca7153d72dbe3d62dea55854fe932aef1bd3d",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1207,
    "optimized_function_code_len": 1458,
    "has_patch": false,
    "original_function_preview": "def get_workflow_cache_file(\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    api_key: Optional[str],\n    workflow_version_id: Optional[str] = None,\n) -> str:\n    sanitized_workspace_id = sani...",
    "optimized_function_only_preview": "def get_workflow_cache_file(\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    api_key: Optional[str],\n    workflow_version_id: Optional[str] = None,\n) -> str:\n    sanitized_workspace_id = sani..."
  },
  {
    "trace_id": "321633ed-4cbf-4276-b446-71c559c306fe",
    "function_name": "register_datapoint",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.16,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 1758,
    "optimized_function_code_len": 3792,
    "has_patch": false,
    "original_function_preview": "def register_datapoint(\n    target_project: str,\n    encoded_image: bytes,\n    local_image_id: str,\n    prediction: Optional[Union[sv.Detections, dict]],\n    api_key: str,\n    batch_name: str,\n    tag...",
    "optimized_function_only_preview": "def register_datapoint(\n    target_project: str,\n    encoded_image: bytes,\n    local_image_id: str,\n    prediction: Optional[Union[sv.Detections, dict]],\n    api_key: str,\n    batch_name: str,\n    tag..."
  },
  {
    "trace_id": "9f6c0572-73bd-45ce-b933-b75948932430",
    "function_name": "RFDETRObjectDetection.postprocess",
    "file_path": "inference/models/rfdetr/rfdetr.py",
    "speedup_x": 0.13,
    "review_quality": "high",
    "pre_optimization_commit": "6078c43bae0aa336aef12e324b9a9008a35d2408",
    "resolution_method": "git_parent",
    "source": "db_events",
    "original_function_code_len": 3321,
    "optimized_function_code_len": 19506,
    "has_patch": true,
    "original_function_preview": "    def postprocess(\n        self,\n        predictions: Tuple[np.ndarray, ...],\n        preproc_return_metadata: PreprocessReturnMetadata,\n        confidence: float = DEFAULT_CONFIDENCE,\n        max_d...",
    "optimized_function_only_preview": "    def postprocess(\n        self,\n        predictions: Tuple[np.ndarray, ...],\n        preproc_return_metadata: PreprocessReturnMetadata,\n        confidence: float = DEFAULT_CONFIDENCE,\n        max_d..."
  },
  {
    "trace_id": "575ba5c8-128b-4265-9c40-ea37c2cc42f2",
    "function_name": "InferenceModelsObjectDetectionAdapter.preprocess",
    "file_path": "inference/core/models/inference_models_adapters.py",
    "speedup_x": 0.12,
    "review_quality": "high",
    "pre_optimization_commit": "459f2b015b4df2c21d99608520607c01d3460822",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 535,
    "optimized_function_code_len": 1842,
    "has_patch": false,
    "original_function_preview": "    def preprocess(self, image: Any, **kwargs):\n        is_batch = isinstance(image, list)\n        images = image if is_batch else [image]\n        np_images: List[np.ndarray] = [\n            load_imag...",
    "optimized_function_only_preview": "    def preprocess(self, image: Any, **kwargs):\n        is_batch = isinstance(image, list)\n        images = image if is_batch else [image]\n        disable_preproc_auto_orient = kwargs.get(\"disable_pre..."
  },
  {
    "trace_id": "e96eab48-c0ed-4bc6-84f4-ff6f4ccb39cb",
    "function_name": "InferenceModelsMoondream2Adapter.caption",
    "file_path": "inference/models/moondream2/moondream2_inference_models.py",
    "speedup_x": 0.11,
    "review_quality": "high",
    "pre_optimization_commit": "7648e452a70ff1aad09f017a0eb2ea4022b7e177",
    "resolution_method": "db_code_match",
    "source": "db_events",
    "original_function_code_len": 323,
    "optimized_function_code_len": 1622,
    "has_patch": false,
    "original_function_preview": "    def caption(self, image_in: Union[Image.Image, np.array], **kwargs):\n        if not isinstance(image_in, np.ndarray):\n            np_img = np.array(image_in)  # RGB\n            bgr_img = cv2.cvtCo...",
    "optimized_function_only_preview": "    def caption(self, image_in: Union[Image.Image, np.array], **kwargs):\n        if not isinstance(image_in, np.ndarray):\n            np_img = np.asarray(image_in)  # RGB\n            bgr_img = cv2.cvt..."
  },
  {
    "trace_id": "ebb67e12-d3a7-43a0-bad6-23cd44314b61",
    "function_name": "load_blocks",
    "file_path": "inference/core/workflows/core_steps/loader.py",
    "speedup_x": 4.09,
    "review_quality": "medium",
    "pre_optimization_commit": "cd270250ecccf2ca814425c27be92511f8e0fa6a",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 4589,
    "optimized_function_code_len": 26628,
    "has_patch": true,
    "original_function_preview": "def load_blocks() -> List[Type[WorkflowBlock]]:\n    return [\n        AbsoluteStaticCropBlockV1,\n        DynamicCropBlockV1,\n        DetectionsFilterBlockV1,\n        DetectionOffsetBlockV1,\n        Dep...",
    "optimized_function_only_preview": "def load_blocks() -> List[Type[WorkflowBlock]]:\n    if not hasattr(load_blocks, \"_blocks\"):\n        load_blocks._blocks = [\n            AbsoluteStaticCropBlockV1,\n            DynamicCropBlockV1,\n     ..."
  },
  {
    "trace_id": "3dd00fd4-4a23-4fe0-934b-e123db8b56ee",
    "function_name": "OverlapManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/analytics/overlap/v1.py",
    "speedup_x": 5.36,
    "review_quality": "high",
    "pre_optimization_commit": "4f2ee45868ebbdd71107e604c762b58c53f6b721",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 258,
    "optimized_function_code_len": 4482,
    "has_patch": true,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [\n            OutputDefinition(\n                name=OUTPUT_KEY,\n                kind=[\n                    OBJECT_DETECTION_PRE...",
    "optimized_function_only_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [\n            OutputDefinition(\n                name=OUTPUT_KEY,\n                kind=[\n                    OBJECT_DETECTION_PRE..."
  },
  {
    "trace_id": "5284a71e-3d51-4c4c-9165-e4da69d70456",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/semantic_segmentation/v1.py",
    "speedup_x": 0.11266584917228695,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 104,
    "optimized_function_code_len": 1092,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return [\"semantic-segmentation\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "4effad50-8188-4255-be8d-6c2871a66ccf",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/object_detection/v2.py",
    "speedup_x": 0.13148396788259067,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 99,
    "optimized_function_code_len": 935,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return [\"object-detection\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "2e8ba96f-9291-4599-a622-f40b23255e4a",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/object_detection/v1.py",
    "speedup_x": 0.11692292101372262,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 99,
    "optimized_function_code_len": 920,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return [\"object-detection\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "be9fee67-5052-44fd-a395-e9359f234087",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/multi_class_classification/v2.py",
    "speedup_x": 0.1380039784581049,
    "review_quality": "high",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 82,
    "optimized_function_code_len": 966,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> list:\n        return [\"classification\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> list:\n        # Return a shallow copy so callers receive a fresh list (preserves original behavior).\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "5f7df79f-5fcf-42c1-981a-cd59c087fb7a",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/keypoint_detection/v2.py",
    "speedup_x": 0.11098577366619714,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 101,
    "optimized_function_code_len": 1012,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return [\"keypoint-detection\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "3e9e68c3-582f-41e8-9ac0-b20eb7a50da8",
    "function_name": "BlockManifest.get_compatible_task_types",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/instance_segmentation/v2.py",
    "speedup_x": 0.1465493945850439,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 104,
    "optimized_function_code_len": 928,
    "has_patch": false,
    "original_function_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return [\"instance-segmentation\"]\n",
    "optimized_function_only_preview": "    def get_compatible_task_types(cls) -> Optional[List[str]]:\n        return _COMPATIBLE_TASK_TYPES.copy()"
  },
  {
    "trace_id": "3ea04ac1-9a5a-4ae7-86e3-f9757fb85f78",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/yolo_world/v1.py",
    "speedup_x": 0.28634958900618085,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 405,
    "optimized_function_code_len": 1149,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return [\n            \"yolo_world/v2-s\",\n          ...",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return _SUPPORTED_MODEL_VARIANTS"
  },
  {
    "trace_id": "85d35d22-806c-4bbc-ad6f-913d3d160e67",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/segment_anything3/v3.py",
    "speedup_x": 0.12582793991335078,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 177,
    "optimized_function_code_len": 1123,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return [\"sam3/sam3_final\"]\n",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return _SUPPORTED_MODEL_VARIANTS.copy()"
  },
  {
    "trace_id": "ec5f6a3f-19cb-45c9-9eb8-5b261e8fc24b",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/moondream2/v1.py",
    "speedup_x": 0.14974510264785262,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 192,
    "optimized_function_code_len": 438,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return [\"moondream2/moondream2_2b_jul24\"]\n",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return _SUPPORTED_MODEL_VARIANTS.copy()"
  },
  {
    "trace_id": "6df4e97b-b43f-4cd0-8381-480aeddf13c0",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/gaze/v1.py",
    "speedup_x": 0.21482246171298922,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 171,
    "optimized_function_code_len": 864,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return [\"gaze/L2CS\"]\n",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return _SUPPORTED_MODEL_VARIANTS.copy()"
  },
  {
    "trace_id": "2e5f8ffc-2db7-46bf-981b-fdba5bcf81f8",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/easy_ocr/v1.py",
    "speedup_x": 0.3066705454545455,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 410,
    "optimized_function_code_len": 1481,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return [\n            \"easy_ocr/english_g2\",\n      ...",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        return _SUPPORTED_MODEL_VARIANTS"
  },
  {
    "trace_id": "c4643598-a7f5-408f-995d-4798efd44b3e",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/clip_comparison/v2.py",
    "speedup_x": 0.2193915663123621,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 313,
    "optimized_function_code_len": 1337,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        from inference.core.workflows.core_steps.models.fo...",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        module = _cached_clip_module()\n        # Build a n..."
  },
  {
    "trace_id": "49c73cf2-76fa-420f-a02a-2778ec6804fb",
    "function_name": "BlockManifest.get_supported_model_variants",
    "file_path": "inference/core/workflows/core_steps/models/foundation/clip_comparison/v1.py",
    "speedup_x": 0.283659805326534,
    "review_quality": "medium",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 313,
    "optimized_function_code_len": 1515,
    "has_patch": false,
    "original_function_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        from inference.core.workflows.core_steps.models.fo...",
    "optimized_function_only_preview": "    def get_supported_model_variants(cls) -> Optional[List[str]]:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        module = _get_clip_v1_module()\n        return list..."
  },
  {
    "trace_id": "219b5d07-9d54-49a7-bc3d-f7bf8a5c5629",
    "function_name": "handle_describe_workflows_blocks_request",
    "file_path": "inference/core/interfaces/http/handlers/workflows.py",
    "speedup_x": 1.4969531997905343,
    "review_quality": "high",
    "pre_optimization_commit": "41e35e60c37b6e8ad32cd3cf3a0b472af8b5baa7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2732,
    "optimized_function_code_len": 1867,
    "has_patch": false,
    "original_function_preview": "def handle_describe_workflows_blocks_request(\n    dynamic_blocks_definitions: Optional[List[DynamicBlockDefinition]] = None,\n    requested_execution_engine_version: Optional[str] = None,\n    api_key: ...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "ad81c7fe-d1a7-4a63-8fd1-b0a8657d9230",
    "function_name": "get_task_type_to_block_mapping",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.3883569922374179,
    "review_quality": "high",
    "pre_optimization_commit": "f297c436b732f5012a51f7b04c135db9133c2370",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1172,
    "optimized_function_code_len": 2947,
    "has_patch": false,
    "original_function_preview": "def get_task_type_to_block_mapping(\n    blocks: Optional[list] = None,\n) -> Dict[str, List[str]]:\n    \"\"\"Build a reverse mapping from task_type to compatible block type identifiers.\n\n    Uses ``get_co...",
    "optimized_function_only_preview": "def get_task_type_to_block_mapping(\n    blocks: Optional[list] = None,\n) -> Dict[str, List[str]]:\n    \"\"\"Build a reverse mapping from task_type to compatible block type identifiers.\n\n    Uses ``get_co..."
  },
  {
    "trace_id": "50730a43-2c7a-45cf-b582-dcc67c2036a7",
    "function_name": "get_cached_foundation_models",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.45940313429973345,
    "review_quality": "high",
    "pre_optimization_commit": "f297c436b732f5012a51f7b04c135db9133c2370",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1782,
    "optimized_function_code_len": 4849,
    "has_patch": false,
    "original_function_preview": "def get_cached_foundation_models(\n    blocks: Optional[list] = None,\n) -> List[Dict[str, Any]]:\n    \"\"\"Return metadata for workflow blocks whose required weights are cached.\n\n    Each block whose mani...",
    "optimized_function_only_preview": "def get_cached_foundation_models(\n    blocks: Optional[list] = None,\n) -> List[Dict[str, Any]]:\n    \"\"\"Return metadata for workflow blocks whose required weights are cached.\n\n    Each block whose mani..."
  },
  {
    "trace_id": "3a26eecd-4ffc-48a9-b42b-aece6eb00038",
    "function_name": "_slugify_model_id",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 10.20682848025384,
    "review_quality": "high",
    "pre_optimization_commit": "f297c436b732f5012a51f7b04c135db9133c2370",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 561,
    "optimized_function_code_len": 1080,
    "has_patch": false,
    "original_function_preview": "def _slugify_model_id(model_id: str) -> str:\n    \"\"\"Reproduce the slug used by inference-models for cache directory names.\n\n    Must stay in sync with\n    ``inference_models.models.auto_loaders.core.s...",
    "optimized_function_only_preview": "def _slugify_model_id(model_id: str) -> str:\n    \"\"\"Reproduce the slug used by inference-models for cache directory names.\n\n    Must stay in sync with\n    ``inference_models.models.auto_loaders.core.s..."
  },
  {
    "trace_id": "c2f72052-57be-427c-a250-dc05986887de",
    "function_name": "is_model_cached",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.22290056307897232,
    "review_quality": "high",
    "pre_optimization_commit": "f297c436b732f5012a51f7b04c135db9133c2370",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1530,
    "optimized_function_code_len": 2991,
    "has_patch": false,
    "original_function_preview": "def is_model_cached(model_id: str) -> bool:\n    \"\"\"Best-effort check whether *model_id* has cached artifacts.\n\n    Checks both the traditional and ``inference-models`` cache layouts,\n    respecting th...",
    "optimized_function_only_preview": "def is_model_cached(model_id: str) -> bool:\n    \"\"\"Best-effort check whether *model_id* has cached artifacts.\n\n    Checks both the traditional and ``inference-models`` cache layouts,\n    respecting th..."
  },
  {
    "trace_id": "09350212-8ca2-4603-8c4f-dae2bc715c05",
    "function_name": "_build_image_entry",
    "file_path": "inference/enterprise/workflows/enterprise_blocks/sinks/event_writer/v1.py",
    "speedup_x": 0.103020961008418,
    "review_quality": "high",
    "pre_optimization_commit": "ad7d91d0150bee8f45dc26ae83f7c499503c8a4d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1127,
    "optimized_function_code_len": 7772,
    "has_patch": false,
    "original_function_preview": "def _build_image_entry(\n    output_image: WorkflowImageData,\n    input_image: Optional[WorkflowImageData] = None,\n    image_label: Optional[str] = None,\n    object_detections: Optional[Any] = None,\n  ...",
    "optimized_function_only_preview": "def _build_image_entry(\n    output_image: WorkflowImageData,\n    input_image: Optional[WorkflowImageData] = None,\n    image_label: Optional[str] = None,\n    object_detections: Optional[Any] = None,\n  ..."
  },
  {
    "trace_id": "d7f98495-d3fc-4892-9c87-e67a39b02bc7",
    "function_name": "_detections_to_v2_instance_segmentations",
    "file_path": "inference/enterprise/workflows/enterprise_blocks/sinks/event_writer/v1.py",
    "speedup_x": 1.1844541446213097,
    "review_quality": "high",
    "pre_optimization_commit": "ad7d91d0150bee8f45dc26ae83f7c499503c8a4d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1592,
    "optimized_function_code_len": 1694,
    "has_patch": false,
    "original_function_preview": "def _detections_to_v2_instance_segmentations(detections: Any) -> List[Dict[str, Any]]:\n    \"\"\"Convert Supervision Detections with masks to v2 instanceSegmentations format.\"\"\"\n    if detections is None...",
    "optimized_function_only_preview": "def _detections_to_v2_instance_segmentations(detections: Any) -> List[Dict[str, Any]]:\n    \"\"\"Convert Supervision Detections with masks to v2 instanceSegmentations format.\"\"\"\n    if detections is None..."
  },
  {
    "trace_id": "e784aca3-8eff-401b-a5c1-8878e6e9f109",
    "function_name": "_build_event_data",
    "file_path": "inference/enterprise/workflows/enterprise_blocks/sinks/event_writer/v1.py",
    "speedup_x": 0.7396972469911406,
    "review_quality": "high",
    "pre_optimization_commit": "ad7d91d0150bee8f45dc26ae83f7c499503c8a4d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1302,
    "optimized_function_code_len": 1831,
    "has_patch": false,
    "original_function_preview": "def _build_event_data(\n    event_schema: str,\n    qc_result: Optional[str] = None,\n    external_id: Optional[str] = None,\n    location: Optional[str] = None,\n    item_count: Optional[int] = None,\n    ...",
    "optimized_function_only_preview": "def _build_event_data(\n    event_schema: str,\n    qc_result: Optional[str] = None,\n    external_id: Optional[str] = None,\n    location: Optional[str] = None,\n    item_count: Optional[int] = None,\n    ..."
  },
  {
    "trace_id": "779a22ea-59c7-4c1e-aac8-61e6a9a843ff",
    "function_name": "load_enterprise_blocks",
    "file_path": "inference/enterprise/workflows/enterprise_blocks/loader.py",
    "speedup_x": 0.451824164253751,
    "review_quality": "high",
    "pre_optimization_commit": "8c3b3b05c065ea3aa960eba47a584d80331fe7ed",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 256,
    "optimized_function_code_len": 1030,
    "has_patch": false,
    "original_function_preview": "def load_enterprise_blocks() -> List[Type[WorkflowBlock]]:\n    return [\n        OPCWriterSinkBlockV1,\n        MQTTWriterSinkBlockV1,\n        PLCBlockV1,\n        ModbusTCPBlockV1,\n        MicrosoftSQLS...",
    "optimized_function_only_preview": "def load_enterprise_blocks() -> List[Type[WorkflowBlock]]:\n    return _ENTERPRISE_BLOCKS"
  },
  {
    "trace_id": "72402a01-b9c2-4c25-8b26-8fcd2c4254fb",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/sinks/twilio/sms/v1.py",
    "speedup_x": 0.14331850873840382,
    "review_quality": "medium",
    "pre_optimization_commit": "94c9904bdcf3ee22d330da1e19f81e3463f2ed07",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 8096,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY.copy()"
  },
  {
    "trace_id": "da566e59-2f09-4230-afdc-4070ccd21d96",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/sinks/slack/notification/v1.py",
    "speedup_x": 0.1395832585090208,
    "review_quality": "medium",
    "pre_optimization_commit": "94c9904bdcf3ee22d330da1e19f81e3463f2ed07",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 7389,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY.copy()"
  },
  {
    "trace_id": "4c711a3d-c738-48e9-90d3-69e0a3cc2d98",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v2.py",
    "speedup_x": 0.10752843288721776,
    "review_quality": "medium",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 7983,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY.copy()"
  },
  {
    "trace_id": "fb95b459-9700-4baa-8e9a-5dce10b8acd3",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.10357735515355307,
    "review_quality": "medium",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 6210,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY_TEMPLATE.copy()"
  },
  {
    "trace_id": "fdcd935d-6569-45d6-b32f-147afc7402ba",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/custom_metadata/v1.py",
    "speedup_x": 0.12107886474770399,
    "review_quality": "high",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 7401,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY_TEMPLATE.copy()"
  },
  {
    "trace_id": "57b7ceaa-0a7d-4908-b833-78b7e2c8bf72",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/models/foundation/lmm/v1.py",
    "speedup_x": 0.12274193093841465,
    "review_quality": "medium",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 1179,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY.copy()"
  },
  {
    "trace_id": "d30df3b9-4142-4a1e-9bff-96aaa882cd95",
    "function_name": "BlockManifest.get_required_cache_artifacts",
    "file_path": "inference/core/workflows/core_steps/models/foundation/clip_comparison/v2.py",
    "speedup_x": 1.04402072135613,
    "review_quality": "high",
    "pre_optimization_commit": "8b77ac4621cef9f731ed9fd25bd10e49372f20ac",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 298,
    "optimized_function_code_len": 1446,
    "has_patch": false,
    "original_function_preview": "    def get_required_cache_artifacts(cls) -> list:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        from inference.core.workflows.core_steps.models.foundation.clip.v...",
    "optimized_function_only_preview": "    def get_required_cache_artifacts(cls) -> list:\n        \"\"\"Return list of model_id variants that can satisfy this block.\"\"\"\n        global _clip_v1_module\n        if _clip_v1_module is None:\n      ..."
  },
  {
    "trace_id": "c150e8d4-55ba-4bba-b4ef-5d7e64b150ed",
    "function_name": "get_cached_models",
    "file_path": "inference/core/interfaces/http/builder/routes.py",
    "speedup_x": 0.8027776299784183,
    "review_quality": "medium",
    "pre_optimization_commit": "82e5d4ab4f32a8ddc47bc41bae39f096fc461350",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 3091,
    "optimized_function_code_len": 8634,
    "has_patch": false,
    "original_function_preview": "async def get_cached_models():\n    \"\"\"Return all models available in the local cache.\n\n    Combines user-trained models discovered via ``model_type.json`` markers\n    with foundation-model blocks whos...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "acd9cec1-af0b-43a2-ae1c-e869aa6cb6a2",
    "function_name": "is_block_cached",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.36264652333600345,
    "review_quality": "high",
    "pre_optimization_commit": "115b2bb4d05b746663b4795d1181f2c66b2777ca",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 877,
    "optimized_function_code_len": 3113,
    "has_patch": false,
    "original_function_preview": "def is_block_cached(artifacts_spec) -> bool:\n    \"\"\"Check whether a block's required cache artifacts are present.\n\n    Handles both formats returned by ``get_required_cache_artifacts()``:\n    - **list...",
    "optimized_function_only_preview": "def is_block_cached(artifacts_spec) -> bool:\n    \"\"\"Check whether a block's required cache artifacts are present.\n\n    Handles both formats returned by ``get_required_cache_artifacts()``:\n    - **list..."
  },
  {
    "trace_id": "f77feb06-7195-4ff0-a487-036cc127e812",
    "function_name": "add_inference_keypoints_to_sv_detections",
    "file_path": "inference/core/workflows/core_steps/common/utils.py",
    "speedup_x": 0.5600008572594778,
    "review_quality": "high",
    "pre_optimization_commit": "a026c11827d12e7f495e828aec3cdd1658fc5f8f",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2317,
    "optimized_function_code_len": 3149,
    "has_patch": false,
    "original_function_preview": "def add_inference_keypoints_to_sv_detections(\n    inference_prediction: List[dict],\n    detections: sv.Detections,\n) -> sv.Detections:\n    if len(inference_prediction) != len(detections):\n        rais...",
    "optimized_function_only_preview": "def add_inference_keypoints_to_sv_detections(\n    inference_prediction: List[dict],\n    detections: sv.Detections,\n) -> sv.Detections:\n    if len(inference_prediction) != len(detections):\n        rais..."
  },
  {
    "trace_id": "2b7a6ce7-150d-43d0-a391-46b6b8ba90e3",
    "function_name": "GLMOCRBlockV1.run_remotely",
    "file_path": "inference/core/workflows/core_steps/models/foundation/glm_ocr/v1.py",
    "speedup_x": 2.243296426557616,
    "review_quality": "medium",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 982,
    "optimized_function_code_len": 1926,
    "has_patch": false,
    "original_function_preview": "    def run_remotely(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n    ) -> BlockResult:\n        api_url = (\n            LOCAL_INF...",
    "optimized_function_only_preview": "    def run_remotely(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n    ) -> BlockResult:\n        api_url = (\n            LOCAL_INF..."
  },
  {
    "trace_id": "6b1bcc1c-0acb-4d9e-963c-65a5542ccb8b",
    "function_name": "BlockManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/models/foundation/glm_ocr/v1.py",
    "speedup_x": 8.3332417710563,
    "review_quality": "high",
    "pre_optimization_commit": "30bef2126dc5d10be627521312d0d2a7fac20b96",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 270,
    "optimized_function_code_len": 1519,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [\n            OutputDefinition(\n                name=\"parsed_output\",\n                kind=[STRING_KIND],\n                descri...",
    "optimized_function_only_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return _CACHED_OUTPUT_DEFINITIONS"
  },
  {
    "trace_id": "df1afec0-f978-4a61-9d7f-8b1d04f978a7",
    "function_name": "default_encoder",
    "file_path": "inference/core/interfaces/webrtc_worker/webrtc.py",
    "speedup_x": 0.1245199084857942,
    "review_quality": "high",
    "pre_optimization_commit": "6be60da204e3270053ac60ebb4b47556380af161",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 137,
    "optimized_function_code_len": 195,
    "has_patch": false,
    "original_function_preview": "def default_encoder(obj: Any) -> Any:\n    if isinstance(obj, bytes):\n        return base64.b64encode(obj).decode(\"ascii\")\n    return obj\n",
    "optimized_function_only_preview": "def default_encoder(obj: Any) -> Any:\n    if isinstance(obj, bytes):\n        return binascii.b2a_base64(obj, newline=False).decode(\"ascii\")\n    return obj"
  },
  {
    "trace_id": "00153aa0-c1f3-4723-bb46-fdb56a1ad5fe",
    "function_name": "BlockManifest.get_air_gapped_availability",
    "file_path": "inference/core/workflows/core_steps/models/foundation/anthropic_claude/v3.py",
    "speedup_x": 0.45016307118217946,
    "review_quality": "high",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 117,
    "optimized_function_code_len": 3644,
    "has_patch": false,
    "original_function_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return {\"available\": False, \"reason\": \"requires_internet\"}\n",
    "optimized_function_only_preview": "    def get_air_gapped_availability(cls) -> dict:\n        return _AIR_GAPPED_AVAILABILITY"
  },
  {
    "trace_id": "c133ab14-0250-443b-ac9d-4ec0ed559f41",
    "function_name": "_get_block_type_identifier",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.10788924446918047,
    "review_quality": "medium",
    "pre_optimization_commit": "f297c436b732f5012a51f7b04c135db9133c2370",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 556,
    "optimized_function_code_len": 848,
    "has_patch": false,
    "original_function_preview": "def _get_block_type_identifier(block) -> str:\n    \"\"\"Extract the canonical ``type`` identifier from a block specification.\"\"\"\n    try:\n        schema = block.manifest_class.model_json_schema()\n       ...",
    "optimized_function_only_preview": "def _get_block_type_identifier(block) -> str:\n    \"\"\"Extract the canonical ``type`` identifier from a block specification.\"\"\"\n    try:\n        schema = block.manifest_class.model_json_schema()\n       ..."
  },
  {
    "trace_id": "60269a07-78e4-422b-8e45-cd3907b13c7b",
    "function_name": "_is_model_cached",
    "file_path": "inference/core/cache/air_gapped.py",
    "speedup_x": 0.23888454256186395,
    "review_quality": "high",
    "pre_optimization_commit": "835af61109f8cab1d2cb51cf93d061ef3a4c5fc7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 768,
    "optimized_function_code_len": 1850,
    "has_patch": false,
    "original_function_preview": "def _is_model_cached(model_id: str) -> bool:\n    \"\"\"Check if *model_id* has cached artifacts in either cache layout.\n\n    Layout 1 (traditional): ``MODEL_CACHE_DIR/{model_id}/`` with files inside.\n   ...",
    "optimized_function_only_preview": "def _is_model_cached(model_id: str) -> bool:\n    \"\"\"Check if *model_id* has cached artifacts in either cache layout.\n\n    Layout 1 (traditional): ``MODEL_CACHE_DIR/{model_id}/`` with files inside.\n   ..."
  },
  {
    "trace_id": "013776ec-6202-49c6-a9ae-d8ccf8a6131f",
    "function_name": "ModelManager.infer_from_request_sync",
    "file_path": "inference/core/managers/base.py",
    "speedup_x": 0.4579793719483347,
    "review_quality": "high",
    "pre_optimization_commit": "607c853289559d1117ee503cf7c703552e1306a7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 4320,
    "optimized_function_code_len": 5737,
    "has_patch": false,
    "original_function_preview": "    def infer_from_request_sync(\n        self, model_id: str, request: InferenceRequest, **kwargs\n    ) -> InferenceResponse:\n        \"\"\"Runs inference on the specified model with the given request.\n\n...",
    "optimized_function_only_preview": "    def infer_from_request_sync(\n        self, model_id: str, request: InferenceRequest, **kwargs\n    ) -> InferenceResponse:\n        \"\"\"Runs inference on the specified model with the given request.\n\n..."
  },
  {
    "trace_id": "bd427253-a203-4e11-98a8-acbc4f1dcfe3",
    "function_name": "DetectionEventLogBlockV1._get_relative_time",
    "file_path": "inference/core/workflows/core_steps/analytics/detection_event_log/v1.py",
    "speedup_x": 0.18604095855143932,
    "review_quality": "high",
    "pre_optimization_commit": "10079df8d89971ef2493e294d6d7d99038802b5e",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1030,
    "optimized_function_code_len": 2775,
    "has_patch": false,
    "original_function_preview": "    def _get_relative_time(\n        self,\n        video_id: str,\n        current_frame: int,\n        metadata: VideoMetadata,\n        fallback_fps: float,\n    ) -> float:\n        \"\"\"Calculate relative...",
    "optimized_function_only_preview": "    def _get_relative_time(\n        self,\n        video_id: str,\n        current_frame: int,\n        metadata: VideoMetadata,\n        fallback_fps: float,\n    ) -> float:\n        \"\"\"Calculate relative..."
  },
  {
    "trace_id": "4ca3d060-c10b-439e-b179-94fbacba1e3f",
    "function_name": "BaseInference.infer",
    "file_path": "inference/core/models/base.py",
    "speedup_x": 1.3246993075301743,
    "review_quality": "medium",
    "pre_optimization_commit": "3d23a0e028b2aba8cea9eaf037e6ebccad8cac97",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 909,
    "optimized_function_code_len": 1931,
    "has_patch": false,
    "original_function_preview": "    def infer(self, image: Any, **kwargs) -> Any:\n        \"\"\"Runs inference on given data.\n        - image:\n            can be a BGR numpy array, filepath, InferenceRequestImage, PIL Image, byte-strin...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "784b482e-eb6b-4cf5-8dcb-382e57d05c99",
    "function_name": "_run_workflow",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/core.py",
    "speedup_x": 0.2187610742682488,
    "review_quality": "high",
    "pre_optimization_commit": "607c853289559d1117ee503cf7c703552e1306a7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1705,
    "optimized_function_code_len": 1727,
    "has_patch": false,
    "original_function_preview": "def _run_workflow(\n    workflow: CompiledWorkflow,\n    runtime_parameters: Dict[str, Any],\n    max_concurrent_steps: int,\n    kinds_serializers: Optional[Dict[str, Callable[[Any], Any]]],\n    serializ...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "f3ade831-2f5e-4826-a60a-a16c4d6c7541",
    "function_name": "wrap_roboflow_api_errors",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 0.27644051667539593,
    "review_quality": "high",
    "pre_optimization_commit": "87db05d80c0789f027cc99ba1491c312b40026f6",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2914,
    "optimized_function_code_len": 5447,
    "has_patch": false,
    "original_function_preview": "def wrap_roboflow_api_errors(\n    http_errors_handlers: Optional[\n        Dict[int, Callable[[Union[requests.exceptions.HTTPError]], None]]\n    ] = None,\n) -> callable:\n    def decorator(function: cal...",
    "optimized_function_only_preview": "def wrap_roboflow_api_errors(\n    http_errors_handlers: Optional[\n        Dict[int, Callable[[Union[requests.exceptions.HTTPError]], None]]\n    ] = None,\n) -> callable:\n    global _cached_default_deco..."
  },
  {
    "trace_id": "5c1ee963-5124-49e8-9563-15a95c0239d3",
    "function_name": "with_route_exceptions",
    "file_path": "inference/core/interfaces/http/error_handlers.py",
    "speedup_x": 5.885736312335115,
    "review_quality": "high",
    "pre_optimization_commit": "71b3048232e5175eccf91d6b484a5dd9199e27aa",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 15810,
    "optimized_function_code_len": 19217,
    "has_patch": false,
    "original_function_preview": "def with_route_exceptions(route):\n    \"\"\"\n    A decorator that wraps a FastAPI route to handle specific exceptions. If an exception\n    is caught, it returns a JSON response with the error message.\n\n ...",
    "optimized_function_only_preview": "def with_route_exceptions(route):\n    \"\"\"\n    A decorator that wraps a FastAPI route to handle specific exceptions. If an exception\n    is caught, it returns a JSON response with the error message.\n\n ..."
  },
  {
    "trace_id": "44c6baa3-2462-47d9-80c6-e208bf81f594",
    "function_name": "_ForceTraceRootSampler.get_description",
    "file_path": "inference/core/telemetry.py",
    "speedup_x": 1.0299888791734935,
    "review_quality": "high",
    "pre_optimization_commit": "3d23a0e028b2aba8cea9eaf037e6ebccad8cac97",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 114,
    "optimized_function_code_len": 306,
    "has_patch": false,
    "original_function_preview": "    def get_description(self) -> str:\n        return f\"ForceTraceRootSampler({self._delegate.get_description()})\"\n",
    "optimized_function_only_preview": "    def get_description(self) -> str:\n        return self._cached_description"
  },
  {
    "trace_id": "8a3b97f7-1814-4488-834f-190e6ca93477",
    "function_name": "record_inference",
    "file_path": "inference/core/telemetry.py",
    "speedup_x": 0.21565895329182055,
    "review_quality": "high",
    "pre_optimization_commit": "3d23a0e028b2aba8cea9eaf037e6ebccad8cac97",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 286,
    "optimized_function_code_len": 699,
    "has_patch": false,
    "original_function_preview": "def record_inference(model_id: str, duration: float) -> None:\n    \"\"\"Record an inference execution.\"\"\"\n    if _metrics is None:\n        return\n    _metrics[\"model_infer_count\"].add(1, {\"model.id\": mod...",
    "optimized_function_only_preview": "def record_inference(model_id: str, duration: float) -> None:\n    \"\"\"Record an inference execution.\"\"\"\n    if _metrics is None:\n        return\n    \n    _cache = _cached_metrics_methods\n    if _cache i..."
  },
  {
    "trace_id": "79b061b7-947c-4157-9cfc-d10e7834a2ee",
    "function_name": "ByteTrackManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/trackers/bytetrack/v1.py",
    "speedup_x": 16.55902700156185,
    "review_quality": "high",
    "pre_optimization_commit": "e450f9a7e8851dc08333f7482154a8d1fc688955",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 99,
    "optimized_function_code_len": 862,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return tracker_describe_outputs()\n",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "71ecf111-ef2d-481f-9c46-1e1fe38f85c8",
    "function_name": "SORTBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/trackers/sort/v1.py",
    "speedup_x": 1.0651544389083694,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 735,
    "optimized_function_code_len": 3549,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        image: WorkflowImageData,\n        detections: sv.Detections,\n        lost_track_buffer: int = 30,\n        minimum_iou_threshold: float = 0.3,\n        minimum_consecu...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "e0b0f41e-67e9-466d-be0b-33967c943ee4",
    "function_name": "InstanceCache.record_instance",
    "file_path": "inference/core/workflows/core_steps/trackers/_base.py",
    "speedup_x": 0.13747348974936976,
    "review_quality": "high",
    "pre_optimization_commit": "e450f9a7e8851dc08333f7482154a8d1fc688955",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 442,
    "optimized_function_code_len": 852,
    "has_patch": false,
    "original_function_preview": "    def record_instance(self, tracker_id: int) -> bool:\n        \"\"\"Record a tracker ID and return whether it was previously seen.\n\n        Returns:\n            True if the tracker_id was already in th...",
    "optimized_function_only_preview": "    def record_instance(self, tracker_id: int) -> bool:\n        \"\"\"Record a tracker ID and return whether it was previously seen.\n\n        Returns:\n            True if the tracker_id was already in th..."
  },
  {
    "trace_id": "fe604e77-00aa-41bd-b347-08581321b2de",
    "function_name": "SORTManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/trackers/sort/v1.py",
    "speedup_x": 16.15681975348376,
    "review_quality": "high",
    "pre_optimization_commit": "e450f9a7e8851dc08333f7482154a8d1fc688955",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 99,
    "optimized_function_code_len": 748,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return tracker_describe_outputs()\n",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "92fe0f54-daaf-448f-b57e-92162e2b8620",
    "function_name": "OCSORTBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/trackers/ocsort/v1.py",
    "speedup_x": 0.5975505904472258,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 902,
    "optimized_function_code_len": 2416,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        image: WorkflowImageData,\n        detections: sv.Detections,\n        lost_track_buffer: int = 30,\n        minimum_iou_threshold: float = 0.1,\n        minimum_consecu...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "1f498919-21c8-490f-be83-843e30ef2a1f",
    "function_name": "ByteTrackManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/transformations/byte_tracker/v1.py",
    "speedup_x": 15.664097790519047,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 98,
    "optimized_function_code_len": 763,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return tracker_describe_outputs()",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "8f7f2378-7585-4973-8fb0-137aa8f32bc2",
    "function_name": "InferenceModelsGLMOCRAdapter.postprocess",
    "file_path": "inference/models/glm_ocr/glm_ocr_inference_models.py",
    "speedup_x": 0.19267289373923105,
    "review_quality": "medium",
    "pre_optimization_commit": "2fcfa233d55edf579db58933ca9bac1b86d85fe6",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 617,
    "optimized_function_code_len": 2607,
    "has_patch": false,
    "original_function_preview": "    def postprocess(\n        self,\n        predictions: torch.Tensor,\n        preprocess_return_metadata: PreprocessReturnMetadata,\n        **kwargs,\n    ) -> List[LMMInferenceResponse]:\n        resul...",
    "optimized_function_only_preview": "    def postprocess(\n        self,\n        predictions: torch.Tensor,\n        preprocess_return_metadata: PreprocessReturnMetadata,\n        **kwargs,\n    ) -> List[LMMInferenceResponse]:\n        resul..."
  },
  {
    "trace_id": "94c04fe2-2e76-4631-8302-2c4729ccb11a",
    "function_name": "prepare_operators_descriptions",
    "file_path": "inference/core/workflows/core_steps/common/query_language/introspection/core.py",
    "speedup_x": 14149.746620452424,
    "review_quality": "high",
    "pre_optimization_commit": "aece4fff835fad9d67e1419e0a86528694765a2b",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 984,
    "optimized_function_code_len": 1824,
    "has_patch": false,
    "original_function_preview": "def prepare_operators_descriptions() -> List[OperatorDescription]:\n    operator_types = [\n        In,\n        StringContains,\n        StringEndsWith,\n        StringStartsWith,\n        NumberLowerEqual...",
    "optimized_function_only_preview": "def prepare_operators_descriptions() -> List[OperatorDescription]:\n    global _CACHED_OPERATORS_DESCRIPTIONS\n    \n    if _CACHED_OPERATORS_DESCRIPTIONS is not None:\n        return _CACHED_OPERATORS_DE..."
  },
  {
    "trace_id": "5824ca45-b2d1-4990-8e4b-d2c580cf34c9",
    "function_name": "prepare_operations_descriptions",
    "file_path": "inference/core/workflows/core_steps/common/query_language/introspection/core.py",
    "speedup_x": 5.262431985316916,
    "review_quality": "high",
    "pre_optimization_commit": "aece4fff835fad9d67e1419e0a86528694765a2b",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1393,
    "optimized_function_code_len": 2681,
    "has_patch": false,
    "original_function_preview": "def prepare_operations_descriptions() -> List[OperationDescription]:\n    operations_chain_schema = OperationsChain.model_json_schema()\n    defs = operations_chain_schema.get(\"$defs\", {})\n    operation...",
    "optimized_function_only_preview": "def prepare_operations_descriptions() -> List[OperationDescription]:\n    operations_chain_schema = OperationsChain.model_json_schema()\n    defs = operations_chain_schema.get(\"$defs\", {})\n    operation..."
  },
  {
    "trace_id": "e3f568b2-940b-40f9-955a-e8ff8c1aff99",
    "function_name": "_get_property_name_options",
    "file_path": "inference/core/workflows/core_steps/common/query_language/introspection/core.py",
    "speedup_x": 0.515270544551777,
    "review_quality": "high",
    "pre_optimization_commit": "aece4fff835fad9d67e1419e0a86528694765a2b",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 685,
    "optimized_function_code_len": 1396,
    "has_patch": false,
    "original_function_preview": "def _get_property_name_options(\n    type_definition: dict,\n    defs: dict,\n) -> Optional[List[str]]:\n    \"\"\"Resolve property_name enum from operation schema when present (e.g. DetectionsProperty).\"\"\"\n...",
    "optimized_function_only_preview": "def _get_property_name_options(\n    type_definition: dict,\n    defs: dict,\n) -> Optional[List[str]]:\n    \"\"\"Resolve property_name enum from operation schema when present (e.g. DetectionsProperty).\"\"\"\n..."
  },
  {
    "trace_id": "0ae79dfb-0c76-4c4e-b97b-ace19c7704df",
    "function_name": "_ref_to_def_name",
    "file_path": "inference/core/workflows/core_steps/common/query_language/introspection/core.py",
    "speedup_x": 0.509847121327117,
    "review_quality": "high",
    "pre_optimization_commit": "aece4fff835fad9d67e1419e0a86528694765a2b",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 296,
    "optimized_function_code_len": 329,
    "has_patch": false,
    "original_function_preview": "def _ref_to_def_name(\n    schema: dict,\n    ref_key: str = \"$ref\",\n) -> Optional[str]:\n    \"\"\"Extract definition name from a JSON Schema object's $ref (e.g. {'$ref': '#/$defs/Foo'} -> 'Foo').\"\"\"\n    r...",
    "optimized_function_only_preview": "def _ref_to_def_name(\n    schema: dict,\n    ref_key: str = \"$ref\",\n) -> Optional[str]:\n    \"\"\"Extract definition name from a JSON Schema object's $ref (e.g. {'$ref': '#/$defs/Foo'} -> 'Foo').\"\"\"\n    r..."
  },
  {
    "trace_id": "e707fac9-0172-49c6-8a24-0abfc8cdb6d1",
    "function_name": "deduct_csv_header",
    "file_path": "inference/core/workflows/core_steps/sinks/s3/v1.py",
    "speedup_x": 7.9001437971153425,
    "review_quality": "high",
    "pre_optimization_commit": "639c8e77ab90d6a43f32fe55a355373ae74e0924",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 96,
    "optimized_function_code_len": 81,
    "has_patch": false,
    "original_function_preview": "def deduct_csv_header(content: str) -> str:\n    return \"\\n\".join(list(content.split(\"\\n\"))[1:])\n",
    "optimized_function_only_preview": "def deduct_csv_header(content: str) -> str:\n    return content.partition(\"\\n\")[2]"
  },
  {
    "trace_id": "05843692-aec2-4f30-bba2-79881e850fef",
    "function_name": "BlockManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/semantic_segmentation/v1.py",
    "speedup_x": 20.922861442472072,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 384,
    "optimized_function_code_len": 1583,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [\n            OutputDefinition(name=INFERENCE_ID_KEY, kind=[INFERENCE_ID_KIND]),\n            OutputDefinition(\n                n...",
    "optimized_function_only_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return _OUTPUT_DEFINITIONS"
  },
  {
    "trace_id": "f1f66349-c618-4678-909f-fdbbf0cf50d9",
    "function_name": "S3SinkBlockV1._upload_separate_file",
    "file_path": "inference/core/workflows/core_steps/sinks/s3/v1.py",
    "speedup_x": 0.1538126447462854,
    "review_quality": "high",
    "pre_optimization_commit": "639c8e77ab90d6a43f32fe55a355373ae74e0924",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 674,
    "optimized_function_code_len": 2674,
    "has_patch": false,
    "original_function_preview": "    def _upload_separate_file(\n        self,\n        s3_client,\n        content: str,\n        file_type: Literal[\"csv\", \"json\", \"txt\"],\n        bucket_name: str,\n        s3_prefix: str,\n        file_n...",
    "optimized_function_only_preview": "    def _upload_separate_file(\n        self,\n        s3_client,\n        content: str,\n        file_type: Literal[\"csv\", \"json\", \"txt\"],\n        bucket_name: str,\n        s3_prefix: str,\n        file_n..."
  },
  {
    "trace_id": "e2ed6943-e598-4857-a03f-a932e8aa4dab",
    "function_name": "list_files",
    "file_path": "inference/core/managers/inference_models_cache_watchdog.py",
    "speedup_x": 0.6644900504969304,
    "review_quality": "high",
    "pre_optimization_commit": "5a720c57f76f195b877fd41ea082c5ca3ecac742",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1195,
    "optimized_function_code_len": 2034,
    "has_patch": false,
    "original_function_preview": "def list_files(path: str) -> List[FileInfo]:\n    path = os.path.abspath(path)\n    if not os.path.exists(path):\n        return []\n    if os.path.islink(path):\n        return []\n    if os.path.isfile(pa...",
    "optimized_function_only_preview": "def list_files(path: str) -> List[FileInfo]:\n    path = os.path.abspath(path)\n    if not os.path.exists(path):\n        return []\n    if os.path.islink(path):\n        return []\n    if os.path.isfile(pa..."
  },
  {
    "trace_id": "f2e3e32d-e049-4f44-9060-3c90e3692762",
    "function_name": "rank_for_deletion",
    "file_path": "inference/core/managers/inference_models_cache_watchdog.py",
    "speedup_x": 0.8837321480253403,
    "review_quality": "high",
    "pre_optimization_commit": "5a720c57f76f195b877fd41ea082c5ca3ecac742",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1171,
    "optimized_function_code_len": 1768,
    "has_patch": false,
    "original_function_preview": "def rank_for_deletion(\n    files: List[FileInfo],\n    now: Optional[datetime] = None,\n    recent_threshold_days: float = RECENT_THRESHOLD_DAYS,\n    warm_threshold_days: float = WARM_THRESHOLD_DAYS,\n  ...",
    "optimized_function_only_preview": "def rank_for_deletion(\n    files: List[FileInfo],\n    now: Optional[datetime] = None,\n    recent_threshold_days: float = RECENT_THRESHOLD_DAYS,\n    warm_threshold_days: float = WARM_THRESHOLD_DAYS,\n  ..."
  },
  {
    "trace_id": "3b2cfefe-bf90-456b-9e2e-a60188196ff8",
    "function_name": "get_workflow_specification",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 0.5560104091973175,
    "review_quality": "medium",
    "pre_optimization_commit": "607c853289559d1117ee503cf7c703552e1306a7",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 3847,
    "optimized_function_code_len": 12894,
    "has_patch": false,
    "original_function_preview": "def get_workflow_specification(\n    api_key: Optional[str],\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    use_cache: bool = True,\n    ephemeral_cache: Optional[BaseCache] = None,\n    workfl...",
    "optimized_function_only_preview": "def get_workflow_specification(\n    api_key: Optional[str],\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    use_cache: bool = True,\n    ephemeral_cache: Optional[BaseCache] = None,\n    workfl..."
  },
  {
    "trace_id": "e2340c87-696d-443e-9615-5c60f1b44ddb",
    "function_name": "InferenceModelsQwen3VLAdapter.map_inference_kwargs",
    "file_path": "inference/models/qwen3vl/qwen3vl_inference_models.py",
    "speedup_x": 1.3860738814158573,
    "review_quality": "medium",
    "pre_optimization_commit": "94995c6f87333bd982d3a4ded917f79d578a0c2f",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 467,
    "optimized_function_code_len": 2723,
    "has_patch": false,
    "original_function_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        pre_processing_overrides = PreProcessingOverrides(\n            disable_contrast_enhancement=kwargs.get(\"disable_preproc_contrast\", Fal...",
    "optimized_function_only_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        pre_processing_overrides = _get_cached_preprocessing_overrides(\n            kwargs.get(\"disable_preproc_contrast\", False),\n           ..."
  },
  {
    "trace_id": "9fed9137-e1b8-4edd-bc3d-fe711b05b1f9",
    "function_name": "InferenceModelsKeyPointsDetectionAdapter.map_inference_kwargs",
    "file_path": "inference/core/models/inference_models_adapters.py",
    "speedup_x": 0.13127884183444277,
    "review_quality": "high",
    "pre_optimization_commit": "459f2b015b4df2c21d99608520607c01d3460822",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 656,
    "optimized_function_code_len": 3123,
    "has_patch": false,
    "original_function_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        if \"request\" in kwargs:\n            keypoint_confidence_threshold = kwargs[\"request\"].keypoint_confidence\n            kwargs[\"key_poin...",
    "optimized_function_only_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        if \"request\" in kwargs:\n            keypoint_confidence_threshold = kwargs[\"request\"].keypoint_confidence\n            kwargs[\"key_poin..."
  },
  {
    "trace_id": "fc44d53a-7c2f-4b37-9544-5cb566a3fe96",
    "function_name": "intersect_masks_per_dimension",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.656500291854472,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 812,
    "optimized_function_code_len": 1177,
    "has_patch": false,
    "original_function_preview": "def intersect_masks_per_dimension(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Set[DynamicBatchIndex]]:\n    \"\"\"Intersect masks at each dimensionality level....",
    "optimized_function_only_preview": "def intersect_masks_per_dimension(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Set[DynamicBatchIndex]]:\n    \"\"\"Intersect masks at each dimensionality level...."
  },
  {
    "trace_id": "1c64d4d6-2d98-4c94-9f87-a3db5df1e019",
    "function_name": "construct_mask_for_all_inputs_dimensionalities",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.5129887829991205,
    "review_quality": "high",
    "pre_optimization_commit": "8087a916a2439f01bf6c577c892bb43e0fa39731",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1397,
    "optimized_function_code_len": 4057,
    "has_patch": false,
    "original_function_preview": "def construct_mask_for_all_inputs_dimensionalities(\n    step_node: StepNode,\n    branching_manager: BranchingManager,\n) -> Tuple[Any, bool]:\n    inputs_dimensionalities = collect_inputs_dimensionaliti...",
    "optimized_function_only_preview": "def construct_mask_for_all_inputs_dimensionalities(\n    step_node: StepNode,\n    branching_manager: BranchingManager,\n) -> Tuple[Any, bool]:\n    inputs_dimensionalities = collect_inputs_dimensionaliti..."
  },
  {
    "trace_id": "cc36ae04-c6c3-4068-b718-3c91f6c3bc46",
    "function_name": "establish_control_flow_edge",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.31966222014197676,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2752,
    "optimized_function_code_len": 3682,
    "has_patch": false,
    "original_function_preview": "def establish_control_flow_edge(\n    source_step_selector: str,\n    target_step_parsed_selector: ParsedSelector,\n    execution_graph: DiGraph,\n) -> DiGraph:\n    if not step_definition_allows_control_f...",
    "optimized_function_only_preview": "def establish_control_flow_edge(\n    source_step_selector: str,\n    target_step_parsed_selector: ParsedSelector,\n    execution_graph: DiGraph,\n) -> DiGraph:\n    allows_control_flow = False\n    for def..."
  },
  {
    "trace_id": "f21854d7-d885-44e2-818a-b0bfb0d8d7d1",
    "function_name": "filter_to_valid_prefix_chains",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.32089148487849195,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1622,
    "optimized_function_code_len": 2621,
    "has_patch": false,
    "original_function_preview": "def filter_to_valid_prefix_chains(\n    per_dim_sets: Dict[int, Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Set[DynamicBatchIndex]]:\n    \"\"\"Keep only indices that form a complete ...",
    "optimized_function_only_preview": "def filter_to_valid_prefix_chains(\n    per_dim_sets: Dict[int, Set[DynamicBatchIndex]],\n    dimensions: Set[int],\n) -> Dict[int, Set[DynamicBatchIndex]]:\n    \"\"\"Keep only indices that form a complete ..."
  },
  {
    "trace_id": "4fc8878d-dd27-427b-9b92-bb0cc1b863cd",
    "function_name": "get_reference_lineage",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.612501453657402,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 3984,
    "optimized_function_code_len": 4345,
    "has_patch": false,
    "original_function_preview": "def get_reference_lineage(\n    step_selector: str,\n    all_data_derived_lineages: List[List[str]],\n    all_control_flow_lineages: List[List[str]],\n    input_data: StepInputData,\n    dimensionality_ref...",
    "optimized_function_only_preview": "def get_reference_lineage(\n    step_selector: str,\n    all_data_derived_lineages: List[List[str]],\n    all_control_flow_lineages: List[List[str]],\n    input_data: StepInputData,\n    dimensionality_ref..."
  },
  {
    "trace_id": "c8a50b18-0431-47c6-88ff-3fb28b95cecf",
    "function_name": "establish_batch_oriented_step_lineage",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.5382143891208309,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1016,
    "optimized_function_code_len": 5600,
    "has_patch": false,
    "original_function_preview": "def establish_batch_oriented_step_lineage(\n    step_selector: str,\n    all_data_derived_lineages: List[List[str]],\n    all_control_flow_lineages: List[List[str]],\n    input_data: StepInputData,\n    di...",
    "optimized_function_only_preview": "def establish_batch_oriented_step_lineage(\n    step_selector: str,\n    all_data_derived_lineages: List[List[str]],\n    all_control_flow_lineages: List[List[str]],\n    input_data: StepInputData,\n    di..."
  },
  {
    "trace_id": "d1ff5e3c-ff86-4b74-8de3-bed228663969",
    "function_name": "ExecutionDataManager._register_control_flow_output_for_non_simd_step",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/manager.py",
    "speedup_x": 1.6508911930995671,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1592,
    "optimized_function_code_len": 2990,
    "has_patch": false,
    "original_function_preview": "    def _register_control_flow_output_for_non_simd_step(\n        self,\n        step_node: StepNode,\n        output: FlowControl,\n    ) -> None:\n        if not step_node.child_execution_branches:\n     ...",
    "optimized_function_only_preview": "    def _register_control_flow_output_for_non_simd_step(\n        self,\n        step_node: StepNode,\n        output: FlowControl,\n    ) -> None:\n        if not step_node.child_execution_branches:\n     ..."
  },
  {
    "trace_id": "a4721d04-7b76-4555-8131-6387a4e69f0d",
    "function_name": "is_control_flow_step",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/utils.py",
    "speedup_x": 0.3374125467644379,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 250,
    "optimized_function_code_len": 785,
    "has_patch": false,
    "original_function_preview": "def is_control_flow_step(execution_graph: DiGraph, node: str) -> bool:\n    if not is_step_node(execution_graph=execution_graph, node=node):\n        return False\n    return execution_graph.nodes[node][...",
    "optimized_function_only_preview": "def is_control_flow_step(execution_graph: DiGraph, node: str) -> bool:\n    # Retrieve the compilation output property once to avoid repeated dict lookups\n    node_prop = execution_graph.nodes[node][NO..."
  },
  {
    "trace_id": "27917af9-868e-4ceb-b6be-e2695443295a",
    "function_name": "establish_step_execution_dimensionality",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 1.3698571068731296,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2252,
    "optimized_function_code_len": 2675,
    "has_patch": false,
    "original_function_preview": "def establish_step_execution_dimensionality(\n    inputs_dimensionalities: Dict[str, Set[int]],\n    control_flow_lineage_support: List[str],\n    output_dimensionality_offset: int,\n) -> int:\n    \"\"\"\n   ...",
    "optimized_function_only_preview": "def establish_step_execution_dimensionality(\n    inputs_dimensionalities: Dict[str, Set[int]],\n    control_flow_lineage_support: List[str],\n    output_dimensionality_offset: int,\n) -> int:\n    \"\"\"\n   ..."
  },
  {
    "trace_id": "44eda0f3-16be-47af-b158-beeac0b8a87d",
    "function_name": "get_lineage_derived_from_control_flow",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.2492806696311797,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1042,
    "optimized_function_code_len": 3511,
    "has_patch": false,
    "original_function_preview": "def get_lineage_derived_from_control_flow(\n    control_flow_steps_selectors: List[str],\n    execution_graph: nx.DiGraph,\n) -> List[List[str]]:\n    \"\"\"\n    Return unique non-empty data lineages from th...",
    "optimized_function_only_preview": "def get_lineage_derived_from_control_flow(\n    control_flow_steps_selectors: List[str],\n    execution_graph: nx.DiGraph,\n) -> List[List[str]]:\n    \"\"\"\n    Return unique non-empty data lineages from th..."
  },
  {
    "trace_id": "5779b128-2cab-4bc0-804d-3bf40871ee8c",
    "function_name": "verify_compatibility_of_input_data_lineage_with_control_flow_lineage",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 1.1129910869973443,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2823,
    "optimized_function_code_len": 5609,
    "has_patch": false,
    "original_function_preview": "def verify_compatibility_of_input_data_lineage_with_control_flow_lineage(\n    step_name: str,\n    inputs_lineage: List[List[str]],\n    control_flow_steps_selectors: List[str],\n    execution_graph: DiG...",
    "optimized_function_only_preview": "def verify_compatibility_of_input_data_lineage_with_control_flow_lineage(\n    step_name: str,\n    inputs_lineage: List[List[str]],\n    control_flow_steps_selectors: List[str],\n    execution_graph: DiG..."
  },
  {
    "trace_id": "c21c77ee-d784-456b-8b2d-b6d6a31c6a2f",
    "function_name": "separate_control_flow_predecessors_from_data_providers",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.8722674638863921,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 669,
    "optimized_function_code_len": 821,
    "has_patch": false,
    "original_function_preview": "def separate_control_flow_predecessors_from_data_providers(\n    execution_graph: DiGraph,\n    node: str,\n) -> Tuple[List[str], List[str]]:\n    all_predecessors = list(execution_graph.predecessors(node...",
    "optimized_function_only_preview": "def separate_control_flow_predecessors_from_data_providers(\n    execution_graph: DiGraph,\n    node: str,\n) -> Tuple[List[str], List[str]]:\n    all_control_flow_predecessors: List[str] = []\n    all_non..."
  },
  {
    "trace_id": "0002ba50-9095-411e-88c3-5ebdfb7d7988",
    "function_name": "_collect_unique_control_flow_lineages_with_step_mapping",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.951922176641884,
    "review_quality": "medium",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1897,
    "optimized_function_code_len": 4641,
    "has_patch": false,
    "original_function_preview": "def _collect_unique_control_flow_lineages_with_step_mapping(\n    control_flow_steps_selectors: List[str],\n    execution_graph: nx.DiGraph,\n) -> Tuple[List[List[str]], Dict[int, List[str]]]:\n    \"\"\"\n  ...",
    "optimized_function_only_preview": "def _collect_unique_control_flow_lineages_with_step_mapping(\n    control_flow_steps_selectors: List[str],\n    execution_graph: nx.DiGraph,\n) -> Tuple[List[List[str]], Dict[int, List[str]]]:\n    \"\"\"\n  ..."
  },
  {
    "trace_id": "1fde2419-152a-4203-9bd3-b8e5650b0594",
    "function_name": "step_definition_allows_control_flow_references",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.8627488853477554,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 258,
    "optimized_function_code_len": 497,
    "has_patch": false,
    "original_function_preview": "def step_definition_allows_control_flow_references(\n    parsed_selector: ParsedSelector,\n) -> bool:\n    return any(\n        definition.selected_element == STEP_AS_SELECTED_ELEMENT\n        for definiti...",
    "optimized_function_only_preview": "def step_definition_allows_control_flow_references(\n    parsed_selector: ParsedSelector,\n) -> bool:\n    target = STEP_AS_SELECTED_ELEMENT\n    for definition in parsed_selector.definition.allowed_refer..."
  },
  {
    "trace_id": "a56974ff-a3fb-4de3-974d-3a70beee6581",
    "function_name": "sequence_apply",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/sequences/base.py",
    "speedup_x": 0.4845884027899415,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 565,
    "optimized_function_code_len": 773,
    "has_patch": false,
    "original_function_preview": "def sequence_apply(\n    value: Any, fun: callable, execution_context: str, **kwargs\n) -> List[Any]:\n    try:\n        return [fun(v, **kwargs) for v in value]\n    except (TypeError, ValueError) as e:\n ...",
    "optimized_function_only_preview": "def sequence_apply(\n    value: Any, fun: callable, execution_context: str, **kwargs\n) -> List[Any]:\n    try:\n        if kwargs:\n            return [fun(v, **kwargs) for v in value]\n        else:\n     ..."
  },
  {
    "trace_id": "5847e541-0af9-4809-932b-d16b55a97157",
    "function_name": "build_sequence_apply_operation",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/core.py",
    "speedup_x": 0.35129740518962077,
    "review_quality": "high",
    "pre_optimization_commit": "90243bdc6278ef7d17b6db09dc1eb5b0d155b4be",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 557,
    "optimized_function_code_len": 6179,
    "has_patch": false,
    "original_function_preview": "def build_sequence_apply_operation(\n    definition: SequenceApply, execution_context: str\n) -> Callable[[T], V]:\n    operations_functions = []\n    for operation in definition.operations:\n        opera...",
    "optimized_function_only_preview": "def build_sequence_apply_operation(\n    definition: SequenceApply, execution_context: str\n) -> Callable[[T], V]:\n    operations_functions = [\n        build_operation(operation_definition=operation, ex..."
  },
  {
    "trace_id": "f777d05c-f3b7-4c73-8b68-220aa677fab5",
    "function_name": "create_dynamic_module",
    "file_path": "inference/core/workflows/execution_engine/v1/dynamic_blocks/block_scaffolding.py",
    "speedup_x": 11.30653022077789,
    "review_quality": "high",
    "pre_optimization_commit": "6a5fec1e3ee3fc67f02b4810039100c99dc65f59",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 3076,
    "optimized_function_code_len": 6094,
    "has_patch": false,
    "original_function_preview": "def create_dynamic_module(\n    block_type_name: str,\n    python_code: PythonCode,\n    module_name: str,\n    api_key: Optional[str] = None,\n    skip_class_eval: Optional[bool] = False,\n) -> types.Modul...",
    "optimized_function_only_preview": "def create_dynamic_module(\n    block_type_name: str,\n    python_code: PythonCode,\n    module_name: str,\n    api_key: Optional[str] = None,\n    skip_class_eval: Optional[bool] = False,\n) -> types.Modul..."
  },
  {
    "trace_id": "886abc7f-50f2-4f3f-8d9b-7d850993c7bc",
    "function_name": "assembly_custom_python_block",
    "file_path": "inference/core/workflows/execution_engine/v1/dynamic_blocks/block_scaffolding.py",
    "speedup_x": 0.6125445120556794,
    "review_quality": "high",
    "pre_optimization_commit": "6a5fec1e3ee3fc67f02b4810039100c99dc65f59",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 4182,
    "optimized_function_code_len": 9260,
    "has_patch": false,
    "original_function_preview": "def assembly_custom_python_block(\n    block_type_name: str,\n    unique_identifier: str,\n    manifest: Type[WorkflowBlockManifest],\n    python_code: PythonCode,\n    api_key: Optional[str] = None,\n    s...",
    "optimized_function_only_preview": "def assembly_custom_python_block(\n    block_type_name: str,\n    unique_identifier: str,\n    manifest: Type[WorkflowBlockManifest],\n    python_code: PythonCode,\n    api_key: Optional[str] = None,\n    s..."
  },
  {
    "trace_id": "3bb32371-8480-4c4b-9a8f-5b3202516327",
    "function_name": "_create_clean_traceback",
    "file_path": "inference/core/workflows/execution_engine/v1/dynamic_blocks/block_scaffolding.py",
    "speedup_x": 2.22346460900176,
    "review_quality": "high",
    "pre_optimization_commit": "f4749c22a8a3beb6045796ed18c98d0e99a6657e",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 934,
    "optimized_function_code_len": 1105,
    "has_patch": false,
    "original_function_preview": "def _create_clean_traceback(\n    error: Exception, python_code: PythonCode, import_lines: int\n) -> str:\n    \"\"\"Create a clean traceback showing only user code with adjusted line numbers.\"\"\"\n    tb = t...",
    "optimized_function_only_preview": "def _create_clean_traceback(\n    error: Exception, python_code: PythonCode, import_lines: int\n) -> str:\n    \"\"\"Create a clean traceback showing only user code with adjusted line numbers.\"\"\"\n    code_l..."
  },
  {
    "trace_id": "9dccafb2-d29d-4786-9a1c-289aad7056b3",
    "function_name": "build_traceback_string",
    "file_path": "inference/core/workflows/execution_engine/v1/dynamic_blocks/block_scaffolding.py",
    "speedup_x": 12.379741533450494,
    "review_quality": "high",
    "pre_optimization_commit": "6a5fec1e3ee3fc67f02b4810039100c99dc65f59",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 661,
    "optimized_function_code_len": 1040,
    "has_patch": false,
    "original_function_preview": "def build_traceback_string(\n    code: Optional[str],\n    line_number: int,\n    function_name: str,\n    error_type: str,\n    error_msg: str,\n) -> str:\n    \"\"\"Build a traceback string from structured er...",
    "optimized_function_only_preview": "def build_traceback_string(\n    code: Optional[str],\n    line_number: int,\n    function_name: str,\n    error_type: str,\n    error_msg: str,\n) -> str:\n    \"\"\"Build a traceback string from structured er..."
  },
  {
    "trace_id": "6d52698f-0731-4950-9253-629642ebd587",
    "function_name": "_build_step_execution_error_response",
    "file_path": "inference/core/interfaces/http/error_handlers.py",
    "speedup_x": 0.1852846448642689,
    "review_quality": "high",
    "pre_optimization_commit": "6a5fec1e3ee3fc67f02b4810039100c99dc65f59",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 862,
    "optimized_function_code_len": 986,
    "has_patch": false,
    "original_function_preview": "def _build_step_execution_error_response(\n    error: StepExecutionError,\n) -> \"WorkflowErrorResponse\":\n    \"\"\"Build a WorkflowErrorResponse for StepExecutionError (runtime errors).\"\"\"\n    from inferen...",
    "optimized_function_only_preview": "def _build_step_execution_error_response(\n    error: StepExecutionError,\n) -> \"WorkflowErrorResponse\":\n    \"\"\"Build a WorkflowErrorResponse for StepExecutionError (runtime errors).\"\"\"\n\n    return Work..."
  },
  {
    "trace_id": "3436e19e-7205-4fbd-9b48-a4103d0621c9",
    "function_name": "InferenceModelsQwen35VLAdapter.predict",
    "file_path": "inference/models/qwen3_5vl/qwen3_5vl_inference_models.py",
    "speedup_x": 2.719797915508924,
    "review_quality": "medium",
    "pre_optimization_commit": "a91e477b2c94b07c4f67f664b68dbe9b45febdb8",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 176,
    "optimized_function_code_len": 1808,
    "has_patch": false,
    "original_function_preview": "    def predict(self, inputs, **kwargs) -> torch.Tensor:\n        mapped_kwargs = self.map_inference_kwargs(kwargs)\n        return self._model.generate(inputs, **mapped_kwargs)\n",
    "optimized_function_only_preview": "    def predict(self, inputs, **kwargs) -> torch.Tensor:\n        mapped_kwargs = self.map_inference_kwargs(kwargs)\n        return self._model.generate(inputs, **mapped_kwargs)"
  },
  {
    "trace_id": "e936cbaf-e28f-4f9d-b0e5-8aac889c5e5a",
    "function_name": "InferenceModelsQwen35VLAdapter.map_inference_kwargs",
    "file_path": "inference/models/qwen3_5vl/qwen3_5vl_inference_models.py",
    "speedup_x": 0.5295936801494229,
    "review_quality": "medium",
    "pre_optimization_commit": "a91e477b2c94b07c4f67f664b68dbe9b45febdb8",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 80,
    "optimized_function_code_len": 1638,
    "has_patch": false,
    "original_function_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        return kwargs\n",
    "optimized_function_only_preview": "    def map_inference_kwargs(self, kwargs: dict) -> dict:\n        return kwargs"
  },
  {
    "trace_id": "d2351ecc-5d16-4355-bb6c-115f19a671b4",
    "function_name": "Qwen35VLBlockV1.run_remotely",
    "file_path": "inference/core/workflows/core_steps/models/foundation/qwen3_5vl/v1.py",
    "speedup_x": 4.644067304821353,
    "review_quality": "high",
    "pre_optimization_commit": "c0249b396cecd814532f6b2a4c0abb4bd6c8c4f3",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1266,
    "optimized_function_code_len": 2643,
    "has_patch": false,
    "original_function_preview": "    def run_remotely(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n   ...",
    "optimized_function_only_preview": "    def run_remotely(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n   ..."
  },
  {
    "trace_id": "794411bc-aa4d-41c5-857d-21e57970fcb0",
    "function_name": "_fetch_workflow_spec_for_validation",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.333960378863972,
    "review_quality": "high",
    "pre_optimization_commit": "2f6a10764cd3da01cb46073d710b1dec32962220",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 701,
    "optimized_function_code_len": 919,
    "has_patch": false,
    "original_function_preview": "def _fetch_workflow_spec_for_validation(\n    api_key: Optional[str],\n    workspace_name: str,\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> Optional[dict]:\n    \"\"\"Fetch a w...",
    "optimized_function_only_preview": "def _fetch_workflow_spec_for_validation(\n    api_key: Optional[str],\n    workspace_name: str,\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> Optional[dict]:\n    \"\"\"Fetch a w..."
  },
  {
    "trace_id": "f0c2d0c8-5b55-4e8f-be6b-50f438b26f9a",
    "function_name": "Qwen35VLBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/models/foundation/qwen3_5vl/v1.py",
    "speedup_x": 0.685419097065631,
    "review_quality": "high",
    "pre_optimization_commit": "c0249b396cecd814532f6b2a4c0abb4bd6c8c4f3",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 862,
    "optimized_function_code_len": 5269,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n        if s...",
    "optimized_function_only_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        model_version: str,\n        prompt: Optional[str],\n        system_prompt: Optional[str],\n    ) -> BlockResult:\n        if s..."
  },
  {
    "trace_id": "a1adcc45-80c0-4cce-8fe7-7f68145d6ea4",
    "function_name": "_deserialize_output_value",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.11004580529026724,
    "review_quality": "high",
    "pre_optimization_commit": "0306c6c070caef88dea09d9b680c659f63b2ccc1",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1533,
    "optimized_function_code_len": 1773,
    "has_patch": false,
    "original_function_preview": "def _deserialize_output_value(\n    output_name: str,\n    raw_value: Any,\n    output_kinds: List[Kind],\n    deserializers: Dict[str, Callable[[str, Any], Any]],\n) -> Any:\n    \"\"\"Deserialize a single ou...",
    "optimized_function_only_preview": "def _deserialize_output_value(\n    output_name: str,\n    raw_value: Any,\n    output_kinds: List[Kind],\n    deserializers: Dict[str, Callable[[str, Any], Any]],\n) -> Any:\n    \"\"\"Deserialize a single ou..."
  },
  {
    "trace_id": "66462362-bc98-4f4f-b1e3-e31b073b73ab",
    "function_name": "_resolve_output_kinds_for_run",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.11638574977128933,
    "review_quality": "high",
    "pre_optimization_commit": "0306c6c070caef88dea09d9b680c659f63b2ccc1",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1047,
    "optimized_function_code_len": 2110,
    "has_patch": false,
    "original_function_preview": "def _resolve_output_kinds_for_run(\n    output_definitions: Dict[str, List[str]],\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> Optional[Dict[str, List[Kind]]]:\n    \"\"\"Deter...",
    "optimized_function_only_preview": "def _resolve_output_kinds_for_run(\n    output_definitions: Dict[str, List[str]],\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> Optional[Dict[str, List[Kind]]]:\n    \"\"\"Deter..."
  },
  {
    "trace_id": "966ad525-0420-4afd-b9c3-2413fc19fe9d",
    "function_name": "_convert_output_descriptions_to_kinds",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.19268043275613683,
    "review_quality": "high",
    "pre_optimization_commit": "0306c6c070caef88dea09d9b680c659f63b2ccc1",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 911,
    "optimized_function_code_len": 1510,
    "has_patch": false,
    "original_function_preview": "def _convert_output_descriptions_to_kinds(\n    outputs_description: Dict[str, Union[List[str], Dict[str, List[str]]]],\n) -> Dict[str, List[Kind]]:\n    \"\"\"Convert ``describe_workflow_outputs()`` result...",
    "optimized_function_only_preview": "def _convert_output_descriptions_to_kinds(\n    outputs_description: Dict[str, Union[List[str], Dict[str, List[str]]]],\n) -> Dict[str, List[Kind]]:\n    \"\"\"Convert ``describe_workflow_outputs()`` result..."
  },
  {
    "trace_id": "6b14b394-5c2f-416b-87de-bef439c001f8",
    "function_name": "_describe_outputs_from_spec",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 11.93871107659098,
    "review_quality": "medium",
    "pre_optimization_commit": "2f6a10764cd3da01cb46073d710b1dec32962220",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 366,
    "optimized_function_code_len": 5025,
    "has_patch": false,
    "original_function_preview": "def _describe_outputs_from_spec(\n    spec: dict,\n) -> Dict[str, Union[List[str], Dict[str, List[str]]]]:\n    \"\"\"Call the standard output discovery to resolve output kinds.\"\"\"\n    from inference.core.w...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "b25c2c26-46de-4858-b0a1-d4e4483a9d32",
    "function_name": "_extract_workflow_caller_ids_from_spec",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.340764780696051,
    "review_quality": "high",
    "pre_optimization_commit": "2f6a10764cd3da01cb46073d710b1dec32962220",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 969,
    "optimized_function_code_len": 1444,
    "has_patch": false,
    "original_function_preview": "def _extract_workflow_caller_ids_from_spec(\n    spec: dict,\n) -> List[Tuple[str, Optional[str]]]:\n    \"\"\"Extract static (workflow_id, workflow_version_id) tuples from a raw\n    workflow specification....",
    "optimized_function_only_preview": "def _extract_workflow_caller_ids_from_spec(\n    spec: dict,\n) -> List[Tuple[str, Optional[str]]]:\n    \"\"\"Extract static (workflow_id, workflow_version_id) tuples from a raw\n    workflow specification...."
  },
  {
    "trace_id": "ff0d25d7-9227-4de0-bc1d-7334507bff41",
    "function_name": "_check_workflow_for_circular_references",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 10.840016169502496,
    "review_quality": "high",
    "pre_optimization_commit": "8b1ad0050d9355954c2fabb7418e30927c22e19d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2331,
    "optimized_function_code_len": 3527,
    "has_patch": false,
    "original_function_preview": "def _check_workflow_for_circular_references(\n    api_key: Optional[str],\n    workspace_name: str,\n    target_workflow_id: str,\n    visited: set,\n    target_workflow_version_id: Optional[str] = None,\n ...",
    "optimized_function_only_preview": "def _check_workflow_for_circular_references(\n    api_key: Optional[str],\n    workspace_name: str,\n    target_workflow_id: str,\n    visited: frozenset,\n    target_workflow_version_id: Optional[str] = N..."
  },
  {
    "trace_id": "8547ec74-8748-4d1a-9fd4-e5cae83c9ef3",
    "function_name": "build_workflow_url",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.2895681220682626,
    "review_quality": "medium",
    "pre_optimization_commit": "2f6a10764cd3da01cb46073d710b1dec32962220",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 404,
    "optimized_function_code_len": 1093,
    "has_patch": false,
    "original_function_preview": "def build_workflow_url(workspace_name: str, workflow_id: str) -> str:\n    \"\"\"Build the URL for calling a workflow on the local inference server.\n\n    Uses LOCAL_INFERENCE_API_URL to call the workflow ...",
    "optimized_function_only_preview": "def build_workflow_url(workspace_name: str, workflow_id: str) -> str:\n    \"\"\"Build the URL for calling a workflow on the local inference server.\n\n    Uses LOCAL_INFERENCE_API_URL to call the workflow ..."
  },
  {
    "trace_id": "1276bc70-8ad4-4e69-b624-7bee0efe621c",
    "function_name": "WorkflowCallerBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/composition/workflow_caller/v1.py",
    "speedup_x": 0.12703817992586777,
    "review_quality": "medium",
    "pre_optimization_commit": "0306c6c070caef88dea09d9b680c659f63b2ccc1",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1962,
    "optimized_function_code_len": 9463,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        workflow_id: str,\n        inputs: Dict[str, Any],\n        request_timeout: int,\n        input_definitions: Dict[str, List[str]],\n        output_definitions: Dict[str...",
    "optimized_function_only_preview": "    def run(\n        self,\n        workflow_id: str,\n        inputs: Dict[str, Any],\n        request_timeout: int,\n        input_definitions: Dict[str, List[str]],\n        output_definitions: Dict[str..."
  },
  {
    "trace_id": "787c6104-2099-4fcc-8ede-cbe79283478b",
    "function_name": "InferencePipeline.init_with_workflow",
    "file_path": "inference/core/interfaces/stream/inference_pipeline.py",
    "speedup_x": 0.10083993313419748,
    "review_quality": "high",
    "pre_optimization_commit": "6f0d879cb9af0cdbd55e1fd2c2a461016dae21f8",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 15540,
    "optimized_function_code_len": 8076,
    "has_patch": false,
    "original_function_preview": "    def init_with_workflow(\n        cls,\n        video_reference: Union[str, int, List[Union[str, int]]],\n        workflow_specification: Optional[dict] = None,\n        workspace_name: Optional[str] =...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "04e1c67d-0b27-450d-9cee-07390142345b",
    "function_name": "format_email_message",
    "file_path": "inference/core/workflows/core_steps/sinks/email_notification/v2.py",
    "speedup_x": 0.3528876109097496,
    "review_quality": "high",
    "pre_optimization_commit": "d919d77736809981dbfaa5d44a7d5aff8c339ded",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1126,
    "optimized_function_code_len": 2641,
    "has_patch": false,
    "original_function_preview": "def format_email_message(\n    message: str,\n    message_parameters: Dict[str, Any],\n    message_parameters_operations: Dict[str, List[AllOperationsType]],\n) -> str:\n    \"\"\"Format email message by repl...",
    "optimized_function_only_preview": "def format_email_message(\n    message: str,\n    message_parameters: Dict[str, Any],\n    message_parameters_operations: Dict[str, List[AllOperationsType]],\n) -> str:\n    \"\"\"Format email message by repl..."
  },
  {
    "trace_id": "c4566e9b-f9f2-4554-b686-93700c77b3d3",
    "function_name": "apply_operations_to_message_parameters",
    "file_path": "inference/core/workflows/core_steps/sinks/email_notification/v2.py",
    "speedup_x": 0.14593291123508287,
    "review_quality": "medium",
    "pre_optimization_commit": "d919d77736809981dbfaa5d44a7d5aff8c339ded",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1542,
    "optimized_function_code_len": 6494,
    "has_patch": false,
    "original_function_preview": "def apply_operations_to_message_parameters(\n    message_parameters: Dict[str, Any],\n    message_parameters_operations: Dict[str, List[AllOperationsType]],\n) -> Dict[str, Any]:\n    \"\"\"\n    Apply per-pa...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "4fee4e4f-dd57-495d-8b80-f425862167f7",
    "function_name": "BlockManifest.describe_outputs",
    "file_path": "inference/core/workflows/core_steps/models/foundation/qwen3_5vl/v1.py",
    "speedup_x": 6.296928284819604,
    "review_quality": "high",
    "pre_optimization_commit": "c0249b396cecd814532f6b2a4c0abb4bd6c8c4f3",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 316,
    "optimized_function_code_len": 819,
    "has_patch": false,
    "original_function_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [\n            OutputDefinition(\n                name=\"parsed_output\",\n                kind=[DICTIONARY_KIND],\n                de...",
    "optimized_function_only_preview": "    def describe_outputs(cls) -> List[OutputDefinition]:\n        return [_PARSED_OUTPUT_DEFINITION]"
  },
  {
    "trace_id": "715517b2-fe67-4727-a7c2-afb8244e8b22",
    "function_name": "_expand_metadata_to_records",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v2.py",
    "speedup_x": 0.6202459015308277,
    "review_quality": "medium",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 1037,
    "optimized_function_code_len": 1190,
    "has_patch": false,
    "original_function_preview": "def _expand_metadata_to_records(\n    metadata: Optional[Union[Dict[str, Any], Batch]],\n    batch_size: int,\n) -> List[Optional[Dict[str, Any]]]:\n    \"\"\"Transpose metadata into a per-image list of dict...",
    "optimized_function_only_preview": "def _expand_metadata_to_records(\n    metadata: Optional[Union[Dict[str, Any], Batch]],\n    batch_size: int,\n) -> List[Optional[Dict[str, Any]]]:\n    \"\"\"Transpose metadata into a per-image list of dict..."
  },
  {
    "trace_id": "5fe7743e-1bf7-449d-a7a4-b5a4f69ec73c",
    "function_name": "RoboflowDatasetUploadBlockV2.run",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v2.py",
    "speedup_x": 8.139850927836438,
    "review_quality": "high",
    "pre_optimization_commit": "5172cfc4e59a6b29dd81a1c98238759ced9f16a0",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2825,
    "optimized_function_code_len": 7956,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        predictions: Optional[Batch[Union[sv.Detections, dict]]],\n        target_project: str,\n        usage_quota_name: str,\n     ...",
    "optimized_function_only_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        predictions: Optional[Batch[Union[sv.Detections, dict]]],\n        target_project: str,\n        usage_quota_name: str,\n     ..."
  },
  {
    "trace_id": "9e33c841-f999-4a4f-a649-5f2a9190863e",
    "function_name": "is_prediction_registration_forbidden",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.4361530609115484,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 405,
    "optimized_function_code_len": 583,
    "has_patch": false,
    "original_function_preview": "def is_prediction_registration_forbidden(\n    prediction: Optional[Union[sv.Detections, dict]],\n) -> bool:\n    if prediction is None:\n        return True\n    if isinstance(prediction, sv.Detections) a...",
    "optimized_function_only_preview": "def is_prediction_registration_forbidden(\n    prediction: Optional[Union[sv.Detections, dict]],\n) -> bool:\n    if prediction is None:\n        return True\n    \n    # Fast path: check if it's a dict fir..."
  },
  {
    "trace_id": "9f6b0ac0-c6e6-4208-a68e-476e7b8baf7f",
    "function_name": "_transpose_metadata_batches",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v2.py",
    "speedup_x": 0.36256670386915957,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 1037,
    "optimized_function_code_len": 1666,
    "has_patch": false,
    "original_function_preview": "def _transpose_metadata_batches(\n    metadata: Optional[Union[Dict[str, Any], Batch]],\n    batch_size: int,\n) -> List[Optional[Dict[str, Any]]]:\n    \"\"\"Transpose metadata into a per-image list of dict...",
    "optimized_function_only_preview": "def _transpose_metadata_batches(\n    metadata: Optional[Union[Dict[str, Any], Batch]],\n    batch_size: int,\n) -> List[Optional[Dict[str, Any]]]:\n    \"\"\"Transpose metadata into a per-image list of dict..."
  },
  {
    "trace_id": "25f9cdf8-8c8a-420c-9f00-41719197f01a",
    "function_name": "register_datapoint_at_roboflow",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.3215856229329653,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1893,
    "optimized_function_code_len": 7068,
    "has_patch": false,
    "original_function_preview": "def register_datapoint_at_roboflow(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    usage_quota_name: str,\n    persist_predictions: boo...",
    "optimized_function_only_preview": "def register_datapoint_at_roboflow(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    usage_quota_name: str,\n    persist_predictions: boo..."
  },
  {
    "trace_id": "6caa6891-5647-4204-99a8-5ba317e13864",
    "function_name": "prepare_parameters",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.11641916089256196,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 4189,
    "optimized_function_code_len": 22016,
    "has_patch": false,
    "original_function_preview": "def prepare_parameters(\n    step_node: StepNode,\n    dynamic_batches_manager: DynamicBatchesManager,\n    masks: Dict[int, Optional[Set[DynamicBatchIndex]]],\n    scalars_discarded: bool,\n    runtime_pa...",
    "optimized_function_only_preview": "def prepare_parameters(\n    step_node: StepNode,\n    dynamic_batches_manager: DynamicBatchesManager,\n    masks: Dict[int, Optional[Set[DynamicBatchIndex]]],\n    scalars_discarded: bool,\n    runtime_pa..."
  },
  {
    "trace_id": "506de95f-ee69-4567-9fee-cf2f1bba8f2d",
    "function_name": "_generate_grid_colors",
    "file_path": "inference/core/interfaces/camera/test_pattern_producer.py",
    "speedup_x": 217.2971048177145,
    "review_quality": "high",
    "pre_optimization_commit": "be557aac76928908f189d4366f62bf9b5433ef2f",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 170,
    "optimized_function_code_len": 791,
    "has_patch": false,
    "original_function_preview": "def _generate_grid_colors(seed: int) -> np.ndarray:\n    rng = np.random.RandomState(seed)\n    return rng.randint(40, 220, size=(GRID_ROWS, GRID_COLS, 3), dtype=np.uint8)\n",
    "optimized_function_only_preview": "def _generate_grid_colors(seed: int) -> np.ndarray:\n    rng = None\n    # Fast path: return a copy of a cached array if available.\n    cached = _CACHE.get(seed)\n    if cached is not None:\n        retur..."
  },
  {
    "trace_id": "48c10dfe-3820-41a5-8261-5a2e9833d3a2",
    "function_name": "RoboflowSemanticSegmentationModelBlockV1._convert_to_sv_detections",
    "file_path": "inference/core/workflows/core_steps/models/roboflow/semantic_segmentation/v1.py",
    "speedup_x": 1.2223439061498738,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 2325,
    "optimized_function_code_len": 3456,
    "has_patch": false,
    "original_function_preview": "    def _convert_to_sv_detections(predictions_dict: Dict) -> sv.Detections:\n        seg_mask_b64 = predictions_dict.get(\"segmentation_mask\", \"\")\n        conf_mask_b64 = predictions_dict.get(\"confidenc...",
    "optimized_function_only_preview": "    def _convert_to_sv_detections(predictions_dict: Dict) -> sv.Detections:\n        seg_mask_b64 = predictions_dict.get(\"segmentation_mask\", \"\")\n        conf_mask_b64 = predictions_dict.get(\"confidenc..."
  },
  {
    "trace_id": "199ed8b8-635a-4ac9-8ca7-832cb6a65dd6",
    "function_name": "WithFixedSizeCache.add_model",
    "file_path": "inference/core/managers/decorators/fixed_size_cache.py",
    "speedup_x": 0.16769860050011387,
    "review_quality": "high",
    "pre_optimization_commit": "c692969e494714fbbb6ba8563429b32dd54fb8a5",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 4907,
    "optimized_function_code_len": 2432,
    "has_patch": false,
    "original_function_preview": "    def add_model(\n        self,\n        model_id: str,\n        api_key: str,\n        model_id_alias: Optional[str] = None,\n        endpoint_type: ModelEndpointType = ModelEndpointType.ORT,\n        co...",
    "optimized_function_only_preview": "N/A"
  },
  {
    "trace_id": "9e589f18-7ce6-4275-a299-dc89858ea3af",
    "function_name": "_is_flash_attn_usable",
    "file_path": "inference/models/qwen3vl/qwen3vl.py",
    "speedup_x": 140.4063954333915,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 377,
    "optimized_function_code_len": 492,
    "has_patch": false,
    "original_function_preview": "def _is_flash_attn_usable() -> bool:\n    \"\"\"Check if flash attention 2 is both installed and supported by the GPU.\"\"\"\n    if not is_flash_attn_2_available():\n        return False\n    try:\n        if n...",
    "optimized_function_only_preview": "def _is_flash_attn_usable() -> bool:\n    \"\"\"Check if flash attention 2 is both installed and supported by the GPU.\"\"\"\n    try:\n        if not torch.cuda.is_available():\n            return False\n      ..."
  },
  {
    "trace_id": "15ee30f1-6e60-4e47-905b-e5f56d9cab93",
    "function_name": "UsageCollector._compute_execution_duration",
    "file_path": "inference/usage_tracking/collector.py",
    "speedup_x": 0.5527596230230375,
    "review_quality": "high",
    "pre_optimization_commit": "f52188ff2e0ddbba9a1e15dd0b1f69b6dabf9fdc",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 407,
    "optimized_function_code_len": 5193,
    "has_patch": false,
    "original_function_preview": "    def _compute_execution_duration(t1: float, t2: float) -> float:\n        raw = t2 - t1\n        if not GCP_SERVERLESS:\n            return raw\n        if apply_duration_minimum is not None:\n         ...",
    "optimized_function_only_preview": "    def _compute_execution_duration(t1: float, t2: float) -> float:\n        raw = t2 - t1\n        if not GCP_SERVERLESS:\n            return raw\n\n        # Localize globals to reduce attribute lookups ..."
  },
  {
    "trace_id": "e50182e7-6211-48fb-9500-0aa48db3cbf1",
    "function_name": "maybe_register_datapoint_at_roboflow",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v2.py",
    "speedup_x": 0.47185871778874366,
    "review_quality": "high",
    "pre_optimization_commit": "5172cfc4e59a6b29dd81a1c98238759ced9f16a0",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1833,
    "optimized_function_code_len": 2027,
    "has_patch": false,
    "original_function_preview": "def maybe_register_datapoint_at_roboflow(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    usage_quota_name: str,\n    data_percentage: f...",
    "optimized_function_only_preview": "def maybe_register_datapoint_at_roboflow(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    usage_quota_name: str,\n    data_percentage: f..."
  },
  {
    "trace_id": "5a3ae559-9d07-4338-9bcd-ced8f44cfaee",
    "function_name": "RoboflowDatasetUploadBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.2623346563771581,
    "review_quality": "high",
    "pre_optimization_commit": "c20359386c628a08bde69f5f3f780cedd782c50c",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2738,
    "optimized_function_code_len": 12573,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        predictions: Optional[Batch[Union[sv.Detections, dict]]],\n        target_project: str,\n        usage_quota_name: str,\n     ...",
    "optimized_function_only_preview": "    def run(\n        self,\n        images: Batch[WorkflowImageData],\n        predictions: Optional[Batch[Union[sv.Detections, dict]]],\n        target_project: str,\n        usage_quota_name: str,\n     ..."
  },
  {
    "trace_id": "e5ba2799-bba7-4b4b-b232-5e44d3c89337",
    "function_name": "execute_registration",
    "file_path": "inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py",
    "speedup_x": 0.16656540743593737,
    "review_quality": "high",
    "pre_optimization_commit": "5172cfc4e59a6b29dd81a1c98238759ced9f16a0",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 3251,
    "optimized_function_code_len": 7338,
    "has_patch": false,
    "original_function_preview": "def execute_registration(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    persist_predictions: bool,\n    usage_quota_name: str,\n    min...",
    "optimized_function_only_preview": "def execute_registration(\n    image: WorkflowImageData,\n    prediction: Optional[Union[sv.Detections, dict]],\n    target_project: str,\n    persist_predictions: bool,\n    usage_quota_name: str,\n    min..."
  },
  {
    "trace_id": "61f42297-886b-43b0-9870-ce3df0448f2e",
    "function_name": "WorkflowImageData.copy_and_replace",
    "file_path": "inference/core/workflows/execution_engine/entities/base.py",
    "speedup_x": 1.0414808656494587,
    "review_quality": "high",
    "pre_optimization_commit": "a60c2b61fd767f1ffe2bb7f27e5aaa900785d661",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 2365,
    "optimized_function_code_len": 4698,
    "has_patch": false,
    "original_function_preview": "    def copy_and_replace(\n        cls, origin_image_data: \"WorkflowImageData\", **kwargs\n    ) -> \"WorkflowImageData\":\n        \"\"\"\n        Creates new instance of `WorkflowImageData` with updated prope...",
    "optimized_function_only_preview": "    def copy_and_replace(\n        cls, origin_image_data: \"WorkflowImageData\", **kwargs\n    ) -> \"WorkflowImageData\":\n        \"\"\"\n        Creates new instance of `WorkflowImageData` with updated prope..."
  },
  {
    "trace_id": "c861d267-1b12-4b92-9fbb-22ba88e53a5e",
    "function_name": "deserialize_image_kind",
    "file_path": "inference/core/workflows/core_steps/common/deserializers.py",
    "speedup_x": 0.42304231092995437,
    "review_quality": "high",
    "pre_optimization_commit": "a60c2b61fd767f1ffe2bb7f27e5aaa900785d661",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 3564,
    "optimized_function_code_len": 7910,
    "has_patch": false,
    "original_function_preview": "def deserialize_image_kind(\n    parameter: str,\n    image: Any,\n    prevent_local_images_loading: bool = False,\n) -> WorkflowImageData:\n    if isinstance(image, WorkflowImageData):\n        return imag...",
    "optimized_function_only_preview": "def deserialize_image_kind(\n    parameter: str,\n    image: Any,\n    prevent_local_images_loading: bool = False,\n) -> WorkflowImageData:\n    if isinstance(image, WorkflowImageData):\n        return imag..."
  },
  {
    "trace_id": "70a9f585-bb0f-411b-8de4-f78fa99a86b3",
    "function_name": "_prepare_workflow_response_cache_key",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 1.3872049562758035,
    "review_quality": "high",
    "pre_optimization_commit": "c0839e1361a6223eb15b804626afc5de2d15dab5",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 538,
    "optimized_function_code_len": 772,
    "has_patch": false,
    "original_function_preview": "def _prepare_workflow_response_cache_key(\n    api_key: Optional[str],\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> str:\n    api_key_hash = (...",
    "optimized_function_only_preview": "def _prepare_workflow_response_cache_key(\n    api_key: Optional[str],\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    workflow_version_id: Optional[str] = None,\n) -> str:\n    api_key_hash = _..."
  },
  {
    "trace_id": "fb279f81-1aa0-4ad0-bdce-3a1fc2fad123",
    "function_name": "load_cached_workflow_response",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 0.38406526568340627,
    "review_quality": "high",
    "pre_optimization_commit": "7ebca7153d72dbe3d62dea55854fe932aef1bd3d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 783,
    "optimized_function_code_len": 3032,
    "has_patch": false,
    "original_function_preview": "def load_cached_workflow_response(\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    api_key: Optional[str],\n    workflow_version_id: Optional[str] = None,\n) -> Optional[dict]:\n    workflow_cac...",
    "optimized_function_only_preview": "def load_cached_workflow_response(\n    workspace_id: WorkspaceID,\n    workflow_id: str,\n    api_key: Optional[str],\n    workflow_version_id: Optional[str] = None,\n) -> Optional[dict]:\n    workflow_cac..."
  },
  {
    "trace_id": "c0499e85-cf3b-4963-946e-fc6b44dd4d17",
    "function_name": "load_kinds",
    "file_path": "inference/core/workflows/core_steps/loader.py",
    "speedup_x": 2.683562116666224,
    "review_quality": "high",
    "pre_optimization_commit": "30bef2126dc5d10be627521312d0d2a7fac20b96",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1162,
    "optimized_function_code_len": 1928,
    "has_patch": false,
    "original_function_preview": "def load_kinds() -> List[Kind]:\n    return [\n        WILDCARD_KIND,\n        IMAGE_KIND,\n        VIDEO_METADATA_KIND,\n        ROBOFLOW_MODEL_ID_KIND,\n        ROBOFLOW_PROJECT_KIND,\n        ROBOFLOW_API...",
    "optimized_function_only_preview": "def load_kinds() -> List[Kind]:\n    return _KINDS_CACHE"
  },
  {
    "trace_id": "74fb7728-6d23-429c-be66-6d3c6863d02f",
    "function_name": "WithFixedSizeCache.memory_pressure_detected",
    "file_path": "inference/core/managers/decorators/fixed_size_cache.py",
    "speedup_x": 916.0940777655444,
    "review_quality": "high",
    "pre_optimization_commit": "43153d3e62370958317efa40875b161d78c28ff6",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1385,
    "optimized_function_code_len": 2526,
    "has_patch": false,
    "original_function_preview": "    def memory_pressure_detected(self) -> bool:\n        return_boolean = False\n        try:\n            import torch\n\n            if torch.cuda.is_available():\n                free_memory, total_memor...",
    "optimized_function_only_preview": "    def memory_pressure_detected(self) -> bool:\n        if not _CUDA_AVAILABLE:\n            return False\n        \n        return_boolean = False\n        try:\n            free_memory, total_memory = to..."
  },
  {
    "trace_id": "1b11b2d7-042d-47e2-af5c-9ba63adcd295",
    "function_name": "try_releasing_cuda_memory",
    "file_path": "inference/core/managers/base.py",
    "speedup_x": 0.21915130869522595,
    "review_quality": "medium",
    "pre_optimization_commit": "3d23a0e028b2aba8cea9eaf037e6ebccad8cac97",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 449,
    "optimized_function_code_len": 771,
    "has_patch": false,
    "original_function_preview": "def try_releasing_cuda_memory() -> None:\n    if not USE_INFERENCE_MODELS:\n        # For now, we only want to have purge CUDA memory when USE_INFERENCE_MODELS is True\n        return None\n    try:\n     ...",
    "optimized_function_only_preview": "def try_releasing_cuda_memory() -> None:\n    if not USE_INFERENCE_MODELS or _torch is None:\n        # For now, we only want to have purge CUDA memory when USE_INFERENCE_MODELS is True\n        # For no..."
  },
  {
    "trace_id": "581f1a3b-f695-4395-99a2-d13e0212f175",
    "function_name": "deserialize_detections_kind",
    "file_path": "inference/core/workflows/core_steps/common/deserializers.py",
    "speedup_x": 0.15433215558971777,
    "review_quality": "high",
    "pre_optimization_commit": "5e6c1f06431d953c2efa8ed663b5f086ece874f3",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 4447,
    "optimized_function_code_len": 8096,
    "has_patch": false,
    "original_function_preview": "def deserialize_detections_kind(\n    parameter: str,\n    detections: Any,\n) -> sv.Detections:\n    if isinstance(detections, sv.Detections):\n        return detections\n    if not isinstance(detections, ...",
    "optimized_function_only_preview": "def deserialize_detections_kind(\n    parameter: str,\n    detections: Any,\n) -> sv.Detections:\n    if isinstance(detections, sv.Detections):\n        return detections\n    if not isinstance(detections, ..."
  },
  {
    "trace_id": "5c4c38cf-6dcd-462d-b716-0151509c4e02",
    "function_name": "compute_detection_areas",
    "file_path": "inference/core/workflows/core_steps/classical_cv/mask_area_measurement/v1.py",
    "speedup_x": 0.4609984079461013,
    "review_quality": "high",
    "pre_optimization_commit": "105f999298f10401ae23311fb501cac6209f12f2",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 1069,
    "optimized_function_code_len": 1335,
    "has_patch": false,
    "original_function_preview": "def compute_detection_areas(detections: sv.Detections) -> List[float]:\n    \"\"\"Compute the area of all detections in square pixels.\n\n    For bounding-box-only detections, areas are computed in a single...",
    "optimized_function_only_preview": "def compute_detection_areas(detections: sv.Detections) -> List[float]:\n    \"\"\"Compute the area of all detections in square pixels.\n\n    For bounding-box-only detections, areas are computed in a single..."
  },
  {
    "trace_id": "e9c228fb-b455-4b73-9038-3954bc2429d4",
    "function_name": "SemanticSegmentationBaseOnnxRoboflowInferenceModel.make_response",
    "file_path": "inference/core/models/semantic_segmentation_base.py",
    "speedup_x": 0.328167485837892,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 1791,
    "optimized_function_code_len": 3904,
    "has_patch": false,
    "original_function_preview": "    def make_response(\n        self, batch_predictions, img_dims, **kwargs\n    ) -> List[SemanticSegmentationInferenceResponse]:\n        # (N,C,H,W)\n        batch_predictions = torch.tensor(batch_pred...",
    "optimized_function_only_preview": "    def make_response(\n        self, batch_predictions, img_dims, **kwargs\n    ) -> List[SemanticSegmentationInferenceResponse]:\n        # (N,C,H,W)\n        # Use as_tensor to avoid an unnecessary cop..."
  },
  {
    "trace_id": "c96f7e25-3382-4409-a6fd-b56f2344cc41",
    "function_name": "get_detection_area",
    "file_path": "inference/core/workflows/core_steps/classical_cv/mask_area_measurement/v1.py",
    "speedup_x": 0.19399736165773107,
    "review_quality": "high",
    "pre_optimization_commit": "0cfcffe66b48e56a5177c252b38aad0ef3f98c27",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 986,
    "optimized_function_code_len": 1432,
    "has_patch": false,
    "original_function_preview": "def get_detection_area(detection: sv.Detections, index: int) -> float:\n    \"\"\"Compute the area of a single detection in square pixels.\n\n    If a segmentation mask is available, the area is computed fr...",
    "optimized_function_only_preview": "def get_detection_area(detection: sv.Detections, index: int) -> float:\n    \"\"\"Compute the area of a single detection in square pixels.\n\n    If a segmentation mask is available, the area is computed fr..."
  },
  {
    "trace_id": "7c4697a6-c848-4a2e-bfee-25ecd10221aa",
    "function_name": "_url_for_safe_logging",
    "file_path": "inference/core/roboflow_api.py",
    "speedup_x": 0.4657431609992291,
    "review_quality": "high",
    "pre_optimization_commit": "7ebca7153d72dbe3d62dea55854fe932aef1bd3d",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 485,
    "optimized_function_code_len": 1401,
    "has_patch": false,
    "original_function_preview": "def _url_for_safe_logging(url: str) -> str:\n    \"\"\"Return a URL safe to log by stripping the query string (and params/fragment).\n\n    Expects the full URL as used for the request (e.g. already wrapped...",
    "optimized_function_only_preview": "def _url_for_safe_logging(url: str) -> str:\n    \"\"\"Return a URL safe to log by stripping the query string (and params/fragment).\n\n    Expects the full URL as used for the request (e.g. already wrapped..."
  },
  {
    "trace_id": "55c0e9b1-992d-4daf-8145-df8038354abd",
    "function_name": "AreaMeasurementBlockV1.run",
    "file_path": "inference/core/workflows/core_steps/classical_cv/mask_area_measurement/v1.py",
    "speedup_x": 0.24539359624877435,
    "review_quality": "high",
    "pre_optimization_commit": "HEAD",
    "resolution_method": "db_code_only",
    "source": "db_features",
    "original_function_code_len": 241,
    "optimized_function_code_len": 2531,
    "has_patch": false,
    "original_function_preview": "    def run(\n        self,\n        predictions: sv.Detections,\n    ) -> BlockResult:\n        areas = []\n        for i in range(len(predictions)):\n            areas.append(get_detection_area(prediction...",
    "optimized_function_only_preview": "    def run(\n        self,\n        predictions: sv.Detections,\n    ) -> BlockResult:\n        n = len(predictions)\n        \n        if n == 0:\n            return {OUTPUT_KEY: []}\n        \n        # Vec..."
  },
  {
    "trace_id": "e2bf66fb-858a-4a40-bfe6-715c87c91217",
    "function_name": "VideoFrameProcessor._check_termination",
    "file_path": "inference/core/interfaces/webrtc_worker/webrtc.py",
    "speedup_x": 0.3554657970526378,
    "review_quality": "high",
    "pre_optimization_commit": "c600366180f51b15836799274e19ad64db60cbab",
    "resolution_method": "db_code_match",
    "source": "db_features",
    "original_function_code_len": 782,
    "optimized_function_code_len": 5372,
    "has_patch": false,
    "original_function_preview": "    def _check_termination(self):\n        \"\"\"Check if we should terminate based on timeout.\n\n        Does NOT set terminate_event \u2014 callers must call _signal_termination()\n        after sending final ...",
    "optimized_function_only_preview": "    def _check_termination(self):\n        \"\"\"Check if we should terminate based on timeout.\n\n        Does NOT set terminate_event \u2014 callers must call _signal_termination()\n        after sending final ..."
  },
  {
    "trace_id": "eef81d00-fd27-43b8-95e3-a94bc552f21d",
    "function_name": "ExperimentalModelManager.is_loaded",
    "file_path": "inference/core/managers/experimental_model_manager.py",
    "speedup_x": 1.31,
    "review_quality": null,
    "pre_optimization_commit": "5a8fee33e5b6a00d403a325d55217306c9de4e64",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 124,
    "optimized_function_code_len": 11163,
    "has_patch": true,
    "original_function_preview": "    def is_loaded(self, model_id: str) -> bool:\n        with self._models_lock:\n            return model_id in self._models\n",
    "optimized_function_only_preview": "    def is_loaded(self, model_id: str) -> bool:\n        return model_id in self._models\n"
  },
  {
    "trace_id": "12b5bd5f-45cc-4f7e-ac07-d0d7624fc71a",
    "function_name": "ModelManager._dispose_model_lock",
    "file_path": "inference/core/managers/base.py",
    "speedup_x": 2.24,
    "review_quality": null,
    "pre_optimization_commit": "1e3077455f0c992cee3f41a15a254a0af1b6a67e",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 458,
    "optimized_function_code_len": 21443,
    "has_patch": true,
    "original_function_preview": "    def _dispose_model_lock(self, model_id: str) -> None:\n        with acquire_with_timeout(lock=self._state_lock) as acquired:\n            if not acquired:\n                raise ModelManagerLockAcqui...",
    "optimized_function_only_preview": "    def _dispose_model_lock(self, model_id: str) -> None:\n        acquired = self._state_lock.acquire(timeout=MODEL_LOCK_ACQUIRE_TIMEOUT)\n        if not acquired:\n            raise ModelManagerLockAcq..."
  },
  {
    "trace_id": "adbc2044-ec0e-4d35-81a9-18cf19b653ea",
    "function_name": "construct_simd_step_input",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.37,
    "review_quality": null,
    "pre_optimization_commit": "714d88cdd217d04c5d5c7235e87efbcb1837e230",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 691,
    "optimized_function_code_len": 42837,
    "has_patch": true,
    "original_function_preview": "def construct_simd_step_input(\n    step_node: StepNode,\n    runtime_parameters: Dict[str, Any],\n    execution_cache: ExecutionCache,\n    dynamic_batches_manager: DynamicBatchesManager,\n    branching_m...",
    "optimized_function_only_preview": "def construct_simd_step_input(\n    step_node: StepNode,\n    runtime_parameters: Dict[str, Any],\n    execution_cache: ExecutionCache,\n    dynamic_batches_manager: DynamicBatchesManager,\n    branching_m..."
  },
  {
    "trace_id": "de7c36bb-eeeb-48c6-9345-41e851be9185",
    "function_name": "find_longest_lineage_support",
    "file_path": "inference/core/workflows/execution_engine/v1/compiler/graph_constructor.py",
    "speedup_x": 0.26,
    "review_quality": null,
    "pre_optimization_commit": "9e7765a4485365e457db24f37888bacfa3e5a40b",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 440,
    "optimized_function_code_len": 82903,
    "has_patch": true,
    "original_function_preview": "def find_longest_lineage_support(\n    all_lineages_of_batch_parameters: List[List[str]],\n) -> Optional[List[str]]:\n    longest_longest_lineage_support = []\n    for lineage in all_lineages_of_batch_par...",
    "optimized_function_only_preview": "def find_longest_lineage_support(\n    all_lineages_of_batch_parameters: List[List[str]],\n) -> Optional[List[str]]:\n    result = max(all_lineages_of_batch_parameters, key=len, default=[])\n    if len(re..."
  },
  {
    "trace_id": "a4faf7da-e81e-4e04-9b78-6bc874d82ca1",
    "function_name": "execute_gpt_4v_request",
    "file_path": "inference/core/workflows/core_steps/models/foundation/openai/v3.py",
    "speedup_x": 1.0,
    "review_quality": null,
    "pre_optimization_commit": "eb6046f90a5ad05d02ad11cd55ed89d8e32cec7a",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 855,
    "optimized_function_code_len": 22576,
    "has_patch": true,
    "original_function_preview": "def execute_gpt_4v_request(\n    roboflow_api_key: str,\n    openai_api_key: str,\n    prompt: List[dict],\n    gpt_model_version: str,\n    max_tokens: int,\n    temperature: Optional[float],\n) -> str:\n   ...",
    "optimized_function_only_preview": "def execute_gpt_4v_request(\n    roboflow_api_key: str,\n    openai_api_key: str,\n    prompt: List[dict],\n    gpt_model_version: str,\n    max_tokens: int,\n    temperature: Optional[float],\n) -> str:\n   ..."
  },
  {
    "trace_id": "git_c155e1bccbd9",
    "function_name": "receive_socket_data",
    "file_path": "inference/core/interfaces/stream_manager/manager_app/communication.py",
    "speedup_x": 0.16,
    "review_quality": null,
    "pre_optimization_commit": "faf922980c7603c01683c8b02580a236d8a1c5f4",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 1416,
    "optimized_function_code_len": 3597,
    "has_patch": true,
    "original_function_preview": "def receive_socket_data(\n    source: socket.socket, header_size: int, buffer_size: int\n) -> dict:\n    header = source.recv(header_size)\n    if len(header) != header_size:\n        raise MalformedHeader...",
    "optimized_function_only_preview": "def receive_socket_data(\n    source: socket.socket, header_size: int, buffer_size: int\n) -> dict:\n    # Read the header part\n    header = source.recv(header_size)\n    if len(header) != header_size:\n  ..."
  },
  {
    "trace_id": "git_bb7edd0a443f",
    "function_name": "get_masks_intersection_up_to_dimension",
    "file_path": "inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py",
    "speedup_x": 0.09,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 405,
    "optimized_function_code_len": 32672,
    "has_patch": true,
    "original_function_preview": "def get_masks_intersection_up_to_dimension(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimension: int,\n) -> Optional[Set[DynamicBatchIndex]]:\n    batch_masks_in_dimension = [\n        {mask_ele...",
    "optimized_function_only_preview": "def get_masks_intersection_up_to_dimension(\n    batch_masks: List[Set[DynamicBatchIndex]],\n    dimension: int,\n) -> Optional[Set[DynamicBatchIndex]]:\n    if not batch_masks:\n        return None\n\n    #..."
  },
  {
    "trace_id": "git_818d2e78e36a",
    "function_name": "build_simple_operation",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/core.py",
    "speedup_x": 0.68,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 484,
    "optimized_function_code_len": 7644,
    "has_patch": true,
    "original_function_preview": "def build_simple_operation(\n    operation_definition: OperationDefinition,\n    operation_function: Callable[[T], V],\n    execution_context: str,\n) -> Callable[[T], V]:\n    predefined_arguments_names =...",
    "optimized_function_only_preview": "def build_simple_operation(\n    operation_definition: OperationDefinition,\n    operation_function: Callable[[T], V],\n    execution_context: str,\n) -> Callable[[T], V]:\n    kwargs = {\n        a: v for ..."
  },
  {
    "trace_id": "git_009c3a92d058",
    "function_name": "from_keypoints_detection_response",
    "file_path": "inference/core/cache/serializers.py",
    "speedup_x": 0.07,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 336,
    "optimized_function_code_len": 4101,
    "has_patch": true,
    "original_function_preview": "def from_keypoints_detection_response(response: KeypointsDetectionInferenceResponse):\n    predictions = []\n    for pred in response.predictions:\n        for keypoint in pred.keypoints:\n            pre...",
    "optimized_function_only_preview": "def from_keypoints_detection_response(response: KeypointsDetectionInferenceResponse):\n    return [\n        {\"class\": keypoint.class_name, \"confidence\": keypoint.confidence}\n        for pred in respons..."
  },
  {
    "trace_id": "git_7988cebce7fd",
    "function_name": "convert_string_color_to_bgr_tuple",
    "file_path": "inference/core/workflows/core_steps/classical_cv/pixel_color_count/v1.py",
    "speedup_x": 0.3,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 857,
    "optimized_function_code_len": 5376,
    "has_patch": true,
    "original_function_preview": "def convert_string_color_to_bgr_tuple(color: str) -> Tuple[int, int, int]:\n    if color.startswith(\"#\") and len(color) == 7:\n        try:\n            return tuple(int(color[i : i + 2], 16) for i in (5...",
    "optimized_function_only_preview": "def convert_string_color_to_bgr_tuple(color: str) -> Tuple[int, int, int]:\n    # Check if color is in hex format\n    if color.startswith(\"#\"):\n        try:\n            if len(color) == 7:\n            ..."
  },
  {
    "trace_id": "git_cf0f6d05af7f",
    "function_name": "count_specific_color_pixels",
    "file_path": "inference/core/workflows/core_steps/classical_cv/pixel_color_count/v1.py",
    "speedup_x": 0.6,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 1094,
    "optimized_function_code_len": 5137,
    "has_patch": true,
    "original_function_preview": "def count_specific_color_pixels(\n    image: np.ndarray,\n    target_color: Union[str, Tuple[int, int, int]],\n    tolerance: int,\n) -> int:\n    \"\"\"\n    Counts the number of pixels that match the target ...",
    "optimized_function_only_preview": "def count_specific_color_pixels(\n    image: np.ndarray,\n    target_color: Union[str, Tuple[int, int, int]],\n    tolerance: int,\n) -> int:\n    \"\"\"\n    Counts the number of pixels that match the target ..."
  },
  {
    "trace_id": "git_afcc3a60c882",
    "function_name": "select_top_confidence_detection",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/detections/base.py",
    "speedup_x": 1.88,
    "review_quality": null,
    "pre_optimization_commit": "5b27747e3e1fb5596d09bc010d506a0ac7bbca7b",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 268,
    "optimized_function_code_len": 17226,
    "has_patch": true,
    "original_function_preview": "def select_top_confidence_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return detections  # No need to deepcopy an empty detections object\n    max_index ...",
    "optimized_function_only_preview": "def select_top_confidence_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return deepcopy(detections)\n    confidence = detections.confidence\n    max_value =..."
  },
  {
    "trace_id": "git_6a3889233146",
    "function_name": "get_average_bounding_box",
    "file_path": "inference/core/workflows/core_steps/fusion/detections_consensus/v1.py",
    "speedup_x": 1.66,
    "review_quality": null,
    "pre_optimization_commit": "f6289ddfeda5115df3edd38dec2ff6885098a6d8",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 193,
    "optimized_function_code_len": 23659,
    "has_patch": true,
    "original_function_preview": "def get_average_bounding_box(detections: sv.Detections) -> Tuple[int, int, int, int]:\n    avg_xyxy: np.ndarray = sum(detections.xyxy) / len(detections)\n    return tuple(avg_xyxy.astype(float))\n",
    "optimized_function_only_preview": "def get_average_bounding_box(detections: sv.Detections) -> Tuple[int, int, int, int]:\n    if len(detections) == 0:\n        return (0.0, 0.0, 0.0, 0.0)\n\n    avg_xyxy = np.mean(detections.xyxy, axis=0)\n..."
  },
  {
    "trace_id": "git_cab7bd9dfa29",
    "function_name": "collect_func_params",
    "file_path": "inference/usage_tracking/utils.py",
    "speedup_x": 3.92,
    "review_quality": null,
    "pre_optimization_commit": "326999fd4355e9ee816e8f257ca3312bd833e5f0",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 943,
    "optimized_function_code_len": 1366,
    "has_patch": true,
    "original_function_preview": "def collect_func_params(\n    func: Callable[[Any], Any], args: Iterable[Any], kwargs: Dict[Any, Any]\n) -> Dict[str, Any]:\n    signature = inspect.signature(func)\n\n    params = {}\n    if args:\n        ...",
    "optimized_function_only_preview": "def collect_func_params(\n    func: Callable[[Any], Any], args: Iterable[Any], kwargs: Dict[Any, Any]\n) -> Dict[str, Any]:\n    signature = func.__code__.co_varnames\n    params = dict(zip(signature, arg..."
  },
  {
    "trace_id": "git_6a764e92a196",
    "function_name": "Batch.broadcast",
    "file_path": "inference/core/workflows/execution_engine/entities/base.py",
    "speedup_x": 0.12,
    "review_quality": null,
    "pre_optimization_commit": "326999fd4355e9ee816e8f257ca3312bd833e5f0",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 489,
    "optimized_function_code_len": 14405,
    "has_patch": true,
    "original_function_preview": "    def broadcast(self, n: int) -> \"Batch\":\n        if n <= 0:\n            raise ValueError(\n                f\"Broadcast to size {n} requested which is invalid operation.\"\n            )\n        if len...",
    "optimized_function_only_preview": "    def broadcast(self, n: int) -> \"Batch\":\n        if n <= 0:\n            raise ValueError(\n                f\"Broadcast to size {n} requested which is an invalid operation.\"\n            )\n\n        nu..."
  },
  {
    "trace_id": "git_84788ea648a7",
    "function_name": "extract_x_coordinate_of_detections_center",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/detections/base.py",
    "speedup_x": 0.35,
    "review_quality": null,
    "pre_optimization_commit": "326999fd4355e9ee816e8f257ca3312bd833e5f0",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 175,
    "optimized_function_code_len": 17359,
    "has_patch": true,
    "original_function_preview": "def extract_x_coordinate_of_detections_center(detections: sv.Detections) -> np.ndarray:\n    return detections.xyxy[:, 0] + (detections.xyxy[:, 2] - detections.xyxy[:, 0]) / 2\n",
    "optimized_function_only_preview": "def extract_x_coordinate_of_detections_center(detections: sv.Detections) -> np.ndarray:\n    # Utilize efficient NumPy broadcasting to compute the center x-coordinate\n    return (detections.xyxy[:, 0] ..."
  },
  {
    "trace_id": "git_6b58b72b86fd",
    "function_name": "select_rightmost_detection",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/detections/base.py",
    "speedup_x": 0.7,
    "review_quality": null,
    "pre_optimization_commit": "326999fd4355e9ee816e8f257ca3312bd833e5f0",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 342,
    "optimized_function_code_len": 17234,
    "has_patch": true,
    "original_function_preview": "def select_rightmost_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return deepcopy(detections)\n    centers_x = detections.get_anchors_coordinates(anchor=P...",
    "optimized_function_only_preview": "def select_rightmost_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return detections\n\n    centers_x = detections.get_anchors_coordinates(anchor=Position.C..."
  },
  {
    "trace_id": "git_0da1c62df7b5",
    "function_name": "select_leftmost_detection",
    "file_path": "inference/core/workflows/core_steps/common/query_language/operations/detections/base.py",
    "speedup_x": 1.53,
    "review_quality": null,
    "pre_optimization_commit": "326999fd4355e9ee816e8f257ca3312bd833e5f0",
    "resolution_method": "git_parent",
    "source": "git",
    "original_function_code_len": 340,
    "optimized_function_code_len": 17452,
    "has_patch": true,
    "original_function_preview": "def select_leftmost_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return deepcopy(detections)\n    centers_x = detections.get_anchors_coordinates(anchor=Po...",
    "optimized_function_only_preview": "def select_leftmost_detection(detections: sv.Detections) -> sv.Detections:\n    if len(detections) == 0:\n        return detections  # Directly return the original empty detections if empty\n\n    centers..."
  }
]