code: def crop_img(
      img,
      anns,
      set_crop_base_path,
      set_img_base_path,
      instance_size=511,
  ):
      """
      Dataset curation
  
      Parameters
      ----------
      img: dic, img
      anns: str, video number
      set_crop_base_path: str, crop result path
      set_img_base_path: str, ori image path
      """
      frame_crop_base_path = os.path.join(
          set_crop_base_path,
          img["file_name"].split("/")[-1].split(".")[0],
      )
      if not os.path.isdir(frame_crop_base_path):
          makedirs(frame_crop_base_path)
      cv2 = try_import_cv2()
      im = cv2.imread(
          "{}/{}".format(set_img_base_path, img["file_name"])
      )
      avg_chans = np.mean(im, axis=(0, 1))
      for trackid, ann in enumerate(anns):
          rect = ann["bbox"]
          bbox = [
              rect[0],
              rect[1],
              rect[0] + rect[2],
              rect[1] + rect[3],
          ]
          if rect[2] <= 0 or rect[3] <= 0:
              continue
          z, x = crop_like_SiamFC(
              im, bbox, instance_size=instance_size, padding=avg_chans
          )
          cv2.imwrite(
              os.path.join(
                  args.download_dir,
                  frame_crop_base_path,
                  "{:06d}.{:02d}.z.jpg".format(0, trackid),
              ),
              z,
          )
          cv2.imwrite(
              os.path.join(
                  args.download_dir,
                  frame_crop_base_path,
                  "{:06d}.{:02d}.x.jpg".format(0, trackid),
              ),
              x,
          )
  
file_path: gluon-cv/scripts/datasets/coco_tracking.py
imports: import argparse
  import zipfile
  import os
  from concurrent import futures
  import time
  import json
  import numpy
  from gluoncv.utils import download, makedirs
  from gluoncv.data.mscoco.utils import try_import_pycocotools
  from gluoncv.utils.filesystem import try_import_cv2
  from gluoncv.utils.data.tracking import crop_like_SiamFC, printProgress
label_desc: Use image node_id 3 for calling a global function with example usage: crop_img(img, anns, set_crop_base_path, set_img_base_path, instance_size) without return types