code: def gen_json(args):
      """transform json and generate train and val json, prepare for tracking dataloader"""
      print("load json (raw vid info), please wait 20 seconds~")
      vid = json.load(
          open(os.path.join(args.download_dir, "vid.json"), "r")
      )
      snippets = dict()
      n_snippets = 0
      n_videos = 0
      for subset in vid:
          for video in subset:
              n_videos += 1
              frames = video["frame"]
              id_set = []
              id_frames = [[]] * 60
              for f, frame in enumerate(frames):
                  objs = frame["objs"]
                  frame_sz = frame["frame_sz"]
                  for obj in objs:
                      trackid = obj["trackid"]
                      occluded = obj["occ"]
                      bbox = obj["bbox"]
                      if trackid not in id_set:
                          id_set.append(trackid)
                          id_frames[trackid] = []
                      id_frames[trackid].append(f)
              if len(id_set) > 0:
                  snippets[video["base_path"]] = dict()
              for selected in id_set:
                  frame_ids = sorted(id_frames[selected])
                  sequences = np.split(
                      frame_ids,
                      np.array(np.where(np.diff(frame_ids) > 1)[0]) + 1,
                  )
                  sequences = [s for s in sequences if len(s) > 1]
                  for seq in sequences:
                      snippet = dict()
                      for frame_id in seq:
                          frame = frames[frame_id]
                          for obj in frame["objs"]:
                              if obj["trackid"] == selected:
                                  o = obj
                                  continue
                          snippet[frame["img_path"].split(".")[0]] = o[
                              "bbox"
                          ]
                      snippets[video["base_path"]][
                          "{:02d}".format(selected)
                      ] = snippet
                      n_snippets += 1
              print(
                  "video: {:d} snippets_num: {:d}".format(
                      n_videos, n_snippets
                  )
              )
  
      train = {k: v for (k, v) in snippets.items() if "train" in k}
      val = {k: v for (k, v) in snippets.items() if "val" in k}
  
      json.dump(
          train,
          open(os.path.join(args.download_dir, "train.json"), "w"),
          indent=4,
          sort_keys=True,
      )
      json.dump(
          val,
          open(os.path.join(args.download_dir, "val.json"), "w"),
          indent=4,
          sort_keys=True,
      )
      print("done!")
  
file_path: gluon-cv/scripts/datasets/ilsvrc_vid.py
imports: import json
  import os
  import glob
  from concurrent import futures
  import time
  import argparse
  import tarfile
  import numpy
  from gluoncv.utils import download, makedirs
  from gluoncv.utils.filesystem import try_import_cv2
  from gluoncv.utils.data.tracking import crop_like_SiamFC, printProgress
label_desc: Use image node_id 6 for calling a global function with example usage: gen_json(args) without return types