code: def visualize_panoptic(
      panoptic,
      label_divisor,
      colormap=None,
      image=None,
      weight=0.5,
      ignore_index=255,
  ):
      """
      Visualize panoptic segmentation results.
  
      Args:
          panoptic (np.ndarray): The panoptic segmentation results, whose shape is (h, w).
          label_divisor (int): Used for conversion between semantic IDs and panoptic IDs.
          colormap (np.ndarray, optional): The color map used for visualization. Default: None.
          image (np.ndarray, optional): The original input image. Merge the segmentation result
              with `image` if it is provided. Default: None.
          weight (float, optional): The weight of original image when performing image merge.
              Default: 0.5.
          ignore_index (int, optional): The class ID to be ignored. Default: 255.
      """
  
      def _random_color(base, max_dist=50):
          # TODO: Jitter in HSV color space
          color = base.astype("int32") + np.random.randint(
              low=-max_dist, high=max_dist + 1, size=3
          )
          # Return an immutable object
          return tuple(np.maximum(0, np.minimum(255, color)))
  
      colored_panoptic = np.zeros(
          (panoptic.shape[0], panoptic.shape[1], 3), dtype=np.uint8
      )
      if colormap is None:
          colormap = _COLORS * 255
      taken_colors = set((0, 0, 0))
  
      for lab in np.unique(panoptic):
          mask = panoptic == lab
          # XXX: The conversion strategy is hard-coded
          cat_id, ins_id = decode_pan_id(lab, label_divisor)
          if cat_id != ignore_index:
              base_color = colormap[cat_id]
          else:
              continue
          color = base_color
          if tuple(base_color) not in taken_colors:
              taken_colors.add(tuple(base_color))
          if ins_id > 0:
              while True:
                  # FIXME: This might result in an infinite loop
                  color = _random_color(base_color)
                  if color not in taken_colors:
                      taken_colors.add(color)
                      break
          colored_panoptic[mask] = color
  
      if image is not None:
          colored_panoptic = cv2.addWeighted(
              image, weight, colored_panoptic, 1 - weight, 0
          )
      return colored_panoptic
  
imports: import cv2
  import numpy
  from .encode import decode_pan_id
label_desc: Use image node_id 4 for calling a global function with example usage: visualize_panoptic(panoptic, label_divisor, colormap, image, weight, ignore_index) and returns: colored_panoptic, tuple