code: def main():
      args = parse_args()
      assert args.task in ["panoptic", "instance"]
      src = args.src
      if args.task == "panoptic":
          annotation_train_path = f"{src}/ade20k_panoptic_train"
          annotation_val_path = f"{src}/ade20k_panoptic_val"
          print("Preparing ADE20K panoptic annotations ...")
          print(
              f"Creating panoptic annotations to {annotation_train_path} and {annotation_val_path} ..."  # noqa
          )
          if os.path.exists(annotation_train_path) or os.path.exists(
              annotation_val_path
          ):
              raise RuntimeError("Panoptic annotations already exist.")
          prepare_panoptic_annotations(src)
          print("Done.")
      else:
          annotation_train_path = f"{src}/ade20k_instance_train"
          annotation_val_path = f"{src}/ade20k_instance_val"
          print("Preparing ADE20K instance annotations ...")
          print(
              f"Creating instance annotations to {annotation_train_path} and {annotation_val_path} ..."  # noqa
          )
          if os.path.exists(annotation_train_path) or os.path.exists(
              annotation_val_path
          ):
              raise RuntimeError("Instance annotations already exist.")
          prepare_instance_annotations(src)
          print("Done.")
  
file_path: mmdetection/tools/dataset_converters/ade20k2coco.py
imports: import argparse
  import json
  import os
  from pathlib import Path
  import numpy
  import pycocotools.mask
  from mmengine.utils import ProgressBar, mkdir_or_exist
  from panopticapi.utils import IdGenerator, save_json
  from PIL import Image
  from mmdet.datasets.ade20k import ADE20KPanopticDataset
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types