code: def visualize_instance(
      instance, save_path, stuff_id=0, image=None, weight=0.5
  ):
      """
      Save instance segmentation results.
  
      Args:
          instance(np.ndarray): The instance segmentation results, shape is (h, w).
          save_path(str): The save path.
          stuff_id(int, optional): Id for background that not want to plot.
          image(np.ndarray, optional): Origin image to prediction, merge instance with
              image if provided. Default: None.
          weight(float, optional): The image weight when merge instance with image. Default: 0.5.
      """
      # Add color map for instance segmentation result.
      ids = np.unique(instance)
      num_colors = len(ids)
      colormap = np.zeros((num_colors, 3), dtype=np.uint8)
      # Maps label to continuous value
      for i in range(num_colors):
          instance[instance == ids[i]] = i
          colormap[i, :] = random_color(maximum=255)
          if ids[i] == stuff_id:
              colormap[i, :] = np.array([0, 0, 0])
      colored_instance = colormap[instance]
  
      if image is not None:
          colored_instance = cv2.addWeighted(
              image, weight, colored_instance, 1 - weight, 0
          )
      cv2.imwrite(save_path, colored_instance)
  
file_path: PaddleSeg/contrib/PanopticDeepLab/utils/visualize.py
imports: import os
  import cv2
  import numpy
  from PIL import Image
label_desc: Use image node_id 4 for calling a global function with example usage: visualize_instance(instance, save_path, stuff_id, image, weight) without return types