code: def _process_panoptic_to_semantic(
      input_panoptic, output_semantic, segments, id_map
  ):
      panoptic = np.asarray(Image.open(input_panoptic), dtype=np.uint32)
      panoptic = rgb2id(panoptic)
      output = np.zeros_like(panoptic, dtype=np.uint8) + 255
      for seg in segments:
          cat_id = seg["category_id"]
          new_cat_id = id_map[cat_id]
          output[panoptic == seg["id"]] = new_cat_id
      Image.fromarray(output).save(output_semantic)
  
file_path: detectron2/datasets/prepare_panoptic_fpn.py
imports: import functools
  import json
  import multiprocessing
  import numpy
  import os
  import time
  from fvcore.common.download import download
  from panopticapi.utils import rgb2id
  from PIL import Image
  from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES
label_desc: Use image node_id 1 for calling a global function with example usage: _process_panoptic_to_semantic(input_panoptic, output_semantic, segments, id_map) without return types