code: def decode_labels(mask, num_images=1, num_classes=20):
      """Decode batch of segmentation masks.
  
      Args:
        mask: result of inference after taking argmax.
        num_images: number of images to decode from the batch.
        num_classes: number of classes to predict (including background).
  
      Returns:
        A batch with num_images RGB images of the same size as the input.
      """
      n, h, w = mask.shape
      assert n >= num_images, (
          "Batch size %d should be greater or equal than number of images to save %d."
          % (
              n,
              num_images,
          )
      )
      outputs = np.zeros((num_images, h, w, 3), dtype=np.uint8)
      for i in range(num_images):
          img = Image.new("RGB", (len(mask[i, 0]), len(mask[i])))
          pixels = img.load()
          for j_, j in enumerate(mask[i, :, :]):
              for k_, k in enumerate(j):
                  if k < num_classes:
                      pixels[k_, j_] = label_colours[k]
          outputs[i] = np.array(img)
      return outputs
  
file_path: insightface/reconstruction/ostec/external/graphonomy/FaceHairMask/graphonomy_inference.py
imports: import cv2
  import torch
  import timeit
  import numpy
  from PIL import Image
  import torch.nn.functional
  from torch.autograd import Variable
  from torchvision import transforms
  from FaceHairMask import graph
  from FaceHairMask import graphonomy_process
label_desc: Use image node_id 5 for calling a global function with example usage: decode_labels(mask, num_images, num_classes) and returns: outputs