code: def _get_mask(mask_paths):
      mask_np = None
      mask_idx = None
      for _, mask_path in enumerate(mask_paths):
          mask_sub = Image.open(mask_path)
          mask_sub_np = np.array(mask_sub, dtype=np.uint8)
          if mask_idx is None:
              mask_idx = np.zeros(mask_sub_np.shape, dtype=np.uint8)
          mask_sub_np = np.ma.masked_array(mask_sub_np, mask=mask_idx)
          mask_idx += np.minimum(mask_sub_np, 1)
  
          if mask_np is None:
              mask_np = mask_sub_np
          else:
              mask_np += mask_sub_np
  
      # nan check
      assert not np.isnan(np.sum(mask_np))
  
      # categories check
      assert np.max(mask_np) <= 18 and np.min(mask_np) >= 0
  
      mask = Image.fromarray(mask_np)
  
      return mask
  
file_path: gluon-cv/gluoncv/data/mhp.py
imports: import os
  import numpy
  from PIL import Image
  from PIL import ImageFile
  import mxnet
  from .segbase import SegmentationDataset
label_desc: Use image node_id 2 for calling a global function with example usage: _get_mask(mask_paths) and returns: mask