code: def crop_object_predictions(
      image: np.ndarray,
      object_prediction_list,
      output_dir: str = "",
      file_name: str = "prediction_visual",
      export_format: str = "png",
  ):
      """
      Crops bounding boxes over the source image and exports it to output folder.
      Arguments:
          object_predictions: a list of prediction.ObjectPrediction
          output_dir: directory for resulting visualization to be exported
          file_name: exported file will be saved as: output_dir+file_name+".png"
          export_format: can be specified as 'jpg' or 'png'
      """
      # create output folder if not present
      Path(output_dir).mkdir(parents=True, exist_ok=True)
      # add bbox and mask to image if present
      for ind, object_prediction in enumerate(object_prediction_list):
          # deepcopy object_prediction_list so that original is not altered
          object_prediction = object_prediction.deepcopy()
          bbox = object_prediction.bbox.to_xyxy()
          category_id = object_prediction.category.id
          # crop detections
          # deepcopy crops so that original is not altered
          cropped_img = copy.deepcopy(
              image[
                  int(bbox[1]) : int(bbox[3]),
                  int(bbox[0]) : int(bbox[2]),
                  :,
              ]
          )
          save_path = os.path.join(
              output_dir,
              file_name
              + "_box"
              + str(ind)
              + "_class"
              + str(category_id)
              + "."
              + export_format,
          )
          cv2.imwrite(
              save_path, cv2.cvtColor(cropped_img, cv2.COLOR_RGB2BGR)
          )
  
imports: import copy
  import os
  import random
  import time
  from typing import List, Optional, Union
  import cv2
  import numpy
  import requests
  from PIL import Image
  from sahi.utils.file import Path
label_desc: Use image node_id 1 for calling a global function with example usage: crop_object_predictions(image, object_prediction_list, output_dir, file_name, export_format) without return types