code: def draw_colored_masks(
      opts,
      orig_image: Image.Image,
      pred_mask: Tensor,
      target_mask: Tensor,
      file_name: str,
      results_location: str,
      color_map: Optional[List] = None,
  ) -> None:
      """Apply color map to segmentation masks"""
  
      alpha = getattr(
          opts, "evaluation.segmentation.overlay_mask_weight", 0.5
      )
      save_overlay_rgb_pred = getattr(
          opts, "evaluation.segmentation.save_overlay_rgb_pred", False
      )
  
      if color_map is None:
          color_map = Colormap().get_color_map_list()
  
      # convert predicted tensor to PIL images, apply color map and save
      pred_mask_pil = F_vision.to_pil_image(pred_mask.byte())
      pred_mask_pil.putpalette(color_map)
      pred_mask_pil = pred_mask_pil.convert("RGB")
      pred_color_mask_dir = "{}/predictions_cmap".format(
          results_location
      )
      if not os.path.isdir(pred_color_mask_dir):
          os.makedirs(pred_color_mask_dir, exist_ok=True)
      color_mask_f_name = "{}/{}".format(pred_color_mask_dir, file_name)
      pred_mask_pil.save(color_mask_f_name)
      logger.log(
          "Predicted mask is saved at: {}".format(color_mask_f_name)
      )
  
      if target_mask is not None:
          # convert target tensor to PIL images, apply colormap, and save
          target_mask_pil = F_vision.to_pil_image(target_mask.byte())
          target_mask_pil.putpalette(color_map)
          target_mask_pil = target_mask_pil.convert("RGB")
          target_color_mask_dir = "{}/gt_cmap".format(results_location)
          if not os.path.isdir(target_color_mask_dir):
              os.makedirs(target_color_mask_dir, exist_ok=True)
          gt_color_mask_f_name = "{}/{}".format(
              target_color_mask_dir, file_name
          )
          target_mask_pil.save(gt_color_mask_f_name)
          logger.log(
              "Target mask is saved at: {}".format(color_mask_f_name)
          )
  
      if save_overlay_rgb_pred and orig_image is not None:
          # overlay predicted mask on top of original image and save
  
          if pred_mask_pil.size != orig_image.size:
              # resize if input image size is not the same as predicted mask.
              # this is likely in case of labeled datasets where we use transforms on the input image
              orig_image = F_vision.resize(
                  orig_image,
                  size=pred_mask_pil.size[::-1],
                  interpolation=F_vision.InterpolationMode.BILINEAR,
              )
  
          overlayed_img = Image.blend(
              pred_mask_pil, orig_image, alpha=alpha
          )
          overlay_mask_dir = "{}/predictions_overlay".format(
              results_location
          )
          if not os.path.isdir(overlay_mask_dir):
              os.makedirs(overlay_mask_dir, exist_ok=True)
          overlay_mask_f_name = "{}/{}".format(
              overlay_mask_dir, file_name
          )
          overlayed_img.save(overlay_mask_f_name)
          logger.log(
              "RGB image blended with mask is saved at: {}".format(
                  overlay_mask_f_name
              )
          )
  
          # save original image
          rgb_image_dir = "{}/rgb_images".format(results_location)
          if not os.path.isdir(rgb_image_dir):
              os.makedirs(rgb_image_dir, exist_ok=True)
          rgb_image_f_name = "{}/{}".format(rgb_image_dir, file_name)
          orig_image.save(rgb_image_f_name)
          logger.log(
              "Original RGB image is saved at: {}".format(
                  overlay_mask_f_name
              )
          )
  
imports: import copy
  import glob
  import os
  from typing import List, Optional, Tuple
  import torch
  from PIL import Image
  from torch import Tensor, nn
  from torch.nn import functional
  from torchvision.transforms import functional
  from tqdm import tqdm
  from common import SUPPORTED_IMAGE_EXTNS
  from cvnets import get_model
  from data import create_test_loader
  from engine.utils import autocast_fn
  from metrics.confusion_mat import ConfusionMatrix
  from options.opts import get_training_arguments
  from utils import logger, resources
  from utils.color_map import Colormap
  from utils.common_utils import create_directories, device_setup
  from utils.ddp_utils import is_master
  from utils.download_utils import get_local_path
  from utils.tensor_utils import image_size_from_opts
  from utils.visualization_utils import convert_to_cityscape_format
label_desc: Use image node_id 3 for calling a global function with example usage: draw_colored_masks(opts, orig_image, pred_mask, target_mask, file_name, results_location, color_map) without return types