code: def get_segmentation_image(
      masks: np.ndarray,
      input_size: Tuple,
      target_size: Tuple,
      stuff_equiv_classes,
      deduplicate=False,
  ):
      h, w = input_size
      final_h, final_w = target_size
  
      m_id = scipy.special.softmax(masks.transpose(0, 1), -1)
  
      if m_id.shape[-1] == 0:
          # We didn't detect any mask :(
          m_id = np.zeros((h, w), dtype=np.int64)
      else:
          m_id = m_id.argmax(-1).reshape(h, w)
  
      if deduplicate:
          # Merge the masks corresponding to the same stuff class
          for equiv in stuff_equiv_classes.values():
              for eq_id in equiv:
                  m_id[m_id == eq_id] = equiv[0]
  
      seg_img = id_to_rgb(m_id)
      seg_img = resize(
          seg_img,
          (final_w, final_h),
          resample=PILImageResampling.NEAREST,
      )
      return seg_img
  
imports: import io
  import pathlib
  from collections import defaultdict
  from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union
  import numpy
  from ...feature_extraction_utils import BatchFeature
  from ...image_processing_utils import BaseImageProcessor, get_size_dict
  from ...image_transforms import PaddingMode, center_to_corners_format, corners_to_center_format, id_to_rgb, pad, rescale, resize, rgb_to_id, to_channel_dimension_format
  from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, AnnotationFormat, AnnotationType, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_list_of_images, to_numpy_array, valid_images, validate_annotations
  from ...utils import TensorType, is_flax_available, is_jax_tensor, is_scipy_available, is_tf_available, is_tf_tensor, is_torch_available, is_torch_tensor, is_vision_available, logging
label_desc: Use image node_id 13 for calling a global function with example usage: get_segmentation_image(masks, input_size, target_size, stuff_equiv_classes, deduplicate) and returns: seg_img