code: def encode_label(self, labelmap):
      ret = np.ones_like(labelmap) * 255
      for idx, label in enumerate(self.mapping):
          ret[labelmap == label] = idx
      return ret.astype(np.uint8)
  
file_path: PaddleSeg/tools/data/convert_cocostuff.py
imports: import os
  import argparse
  import cv2
  import numpy
  from PIL import Image
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling the COCOStuffGenerator obj's underlying member method code with example usage: obj.encode_label(labelmap) and returns: ret