code: def get_masks(self, im, return_panoptic=False):
      panoptic_seg, segments_info = self.get_segmentation(im)
      potential_mask_ids = self.identify_candidates(
          panoptic_seg, segments_info
      )
  
      panoptic_seg_scaled = self._prepare_mask(
          panoptic_seg.detach().cpu().numpy()
      )
      downsampled = self.downsample_mask(panoptic_seg_scaled)
      scene_objects = []
      for segment in segments_info:
          if not segment["isthing"]:
              continue
          mask = downsampled == segment["id"]
          if not np.any(mask):
              continue
          scene_objects.append(mask)
  
      mask_set = []
      for mask_id in potential_mask_ids:
          mask = downsampled == mask_id
          if not np.any(mask):
              continue
  
          if self.rigidness_mode is RigidnessMode.soft:
              foreground = [mask]
          elif self.rigidness_mode is RigidnessMode.rigid:
              foreground = scene_objects
          else:
              raise ValueError(
                  f"Unexpected rigidness_mode: {rigidness_mode}"
              )
  
          masks_params = self._move_mask(mask, foreground)
  
          full_mask = ObjectMask(
              (panoptic_seg == mask_id).detach().cpu().numpy()
          )
  
          for params in masks_params:
              aug_mask = deepcopy(full_mask)
              aug_mask.rescale(params["scaling_factor"], inplace=True)
              if params["horizontal_flip"]:
                  aug_mask.horizontal_flip(inplace=True)
  
              vertical_shift = int(
                  round(aug_mask.height * params["vertical_shift"])
              )
              horizontal_shift = int(
                  round(aug_mask.width * params["horizontal_shift"])
              )
              aug_mask.shift(
                  vertical=vertical_shift,
                  horizontal=horizontal_shift,
                  inplace=True,
              )
              aug_mask = aug_mask.restore_full_mask().astype("uint8")
              if aug_mask.mean() <= self.min_mask_area:
                  continue
              mask_set.append(aug_mask)
  
      if return_panoptic:
          return mask_set, panoptic_seg.detach().cpu().numpy()
      else:
          return mask_set
  
imports: import enum
  from copy import deepcopy
  import numpy
  from skimage import img_as_ubyte
  from skimage.transform import rescale, resize
  from .countless2d import zero_corrected_countless
label_desc: Use image node_id 12 for calling the SegmentationMask obj's underlying member method code with example usage: obj.get_masks(im, return_panoptic) and returns: mask_set,  panoptic_seg, mask_set