code: def save_mask(self, img_id, mode):
      if mode == "train":
          mask = Image.fromarray(
              self._class_to_index(
                  self.train_detail.getMask(img_id),
                  _mapping=self._mapping,
                  _key=self._key,
              )
          )
      elif mode == "val":
          mask = Image.fromarray(
              self._class_to_index(
                  self.val_detail.getMask(img_id),
                  _mapping=self._mapping,
                  _key=self._key,
              )
          )
      filename = img_id["file_name"]
      basename, _ = os.path.splitext(filename)
      if filename.endswith(".jpg"):
          mask_png_name = basename + ".png"
          mask.save(os.path.join(self.label_dir, mask_png_name))
      return basename
  
file_path: PaddleSeg/tools/data/convert_voc2010.py
imports: import argparse
  import os
  import tqdm
  import numpy
  from detail import Detail
  from PIL import Image
label_desc: Use image node_id 3 for calling the PascalContextGenerator obj's underlying member method code with example usage: obj.save_mask(img_id, mode) and returns: basename