code: def shape2label(img_size, shapes, class_name_mapping):
      label = np.zeros(img_size[:2], dtype=np.int32)
      for shape in shapes:
          points = shape["points"]
          class_name = shape["label"]
          shape_type = shape.get("shape_type", None)
          class_id = class_name_mapping[class_name]
          label_mask = shape2mask(img_size[:2], points)
          label[label_mask] = class_id
      return label
  
file_path: PaddleSeg/tools/data/labelme2seg.py
imports: from __future__ import print_function
  import argparse
  import glob
  import math
  import json
  import os
  import os.path
  import shutil
  import numpy
  import PIL.Image
  import PIL.ImageDraw
  import cv2
label_desc: Use image node_id 4 for calling a global function with example usage: shape2label(img_size, shapes, class_name_mapping) and returns: label