code: def visualize_semantic(
      semantic, colormap=None, image=None, weight=0.5
  ):
      """
      Visualize semantic segmentation results.
  
      Args:
          semantic (np.ndarray): The semantic segmenation results, whose shape is (h, w).
          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.
      """
      semantic = semantic.astype("uint8")
      if colormap is None:
          colormap = _COLORS * 255
      colored_semantic = colormap[semantic]
      if image is not None:
          colored_semantic = cv2.addWeighted(
              image, weight, colored_semantic, 1 - weight, 0
          )
      return colored_semantic
  
imports: import cv2
  import numpy
  from .encode import decode_pan_id
label_desc: Use image node_id 2 for calling a global function with example usage: visualize_semantic(semantic, colormap, image, weight) and returns: colored_semantic