code: def cvt_annotations(image_infos, out_json_name):
      out_json = dict()
      img_id = 0
      ann_id = 0
      out_json["images"] = []
      out_json["categories"] = []
      out_json["annotations"] = []
      for image_info in image_infos:
          image_info["id"] = img_id
          anno_infos = image_info.pop("anno_info")
          out_json["images"].append(image_info)
          for anno_info in anno_infos:
              anno_info["image_id"] = img_id
              anno_info["id"] = ann_id
              out_json["annotations"].append(anno_info)
              ann_id += 1
          img_id += 1
      for label in CSLabels.labels:
          if label.hasInstances and not label.ignoreInEval:
              cat = dict(id=label.id, name=label.name)
              out_json["categories"].append(cat)
  
      if len(out_json["annotations"]) == 0:
          out_json.pop("annotations")
  
      dump(out_json, out_json_name)
      return out_json
  
file_path: mmdetection/tools/dataset_converters/cityscapes.py
imports: import argparse
  import glob
  import os.path
  import cityscapesscripts.helpers.labels
  import mmcv
  import numpy
  import pycocotools.mask
  from mmengine.fileio import dump
  from mmengine.utils import Timer, mkdir_or_exist, track_parallel_progress, track_progress
label_desc: Use image node_id 4 for calling a global function with example usage: cvt_annotations(image_infos, out_json_name) and returns: out_json