code: def _panoptic_inference(self, mask_cls, mask_pred):
      scores = F.softmax(mask_cls, axis=1)
      labels = paddle.argmax(scores, axis=1)
      scores = paddle.max(scores, axis=1)
      mask_pred = F.sigmoid(mask_pred)
  
      h, w = mask_pred.shape[-2:]
      ins_id_map = paddle.zeros((h, w), dtype="int64")
      pan_pred = paddle.zeros((h, w), dtype="int64")
  
      keep = (labels != self.num_classes) & (
          scores > self.object_mask_threshold
      )
      keep = paddle.nonzero(keep)
  
      if keep.shape[0] == 0:
          return ins_id_map, pan_pred
  
      cur_scores = paddle.index_select(scores, keep, axis=0)
      cur_classes = paddle.index_select(labels, keep, axis=0)
      cur_masks = paddle.index_select(mask_pred, keep, axis=0)
      cur_mask_cls = paddle.index_select(mask_cls, keep, axis=0)
      cur_mask_cls = cur_mask_cls[:, :-1]
      cur_prob_masks = cur_scores.reshape((-1, 1, 1)) * cur_masks
  
      # Take argmax
      cur_mask_ids = paddle.argmax(cur_prob_masks, axis=0)
      stuff_memory_list = {}
      class_id_tracker = Counter()
      current_segment_id = 0
      for k in range(cur_classes.shape[0]):
          pred_class = int(cur_classes[k])
          isthing = pred_class in self.thing_ids
          mask_area = (cur_mask_ids == k).sum()
          original_area = (cur_masks[k] >= 0.5).sum()
          mask = (cur_mask_ids == k) & (cur_masks[k] >= 0.5)
  
          if mask_area > 0 and original_area > 0 and mask.sum() > 0:
              if mask_area / original_area < self.overlap_threshold:
                  continue
  
              # Merge stuff regions
              if not isthing:
                  pan_pred[mask] = encode_pan_id(
                      pred_class, self.label_divisor
                  )
                  if pred_class in stuff_memory_list.keys():
                      ins_id_map[mask] = stuff_memory_list[pred_class]
                      continue
                  else:
                      stuff_memory_list[pred_class] = (
                          current_segment_id + 1
                      )
              else:
                  class_id_tracker[pred_class] += 1
                  pan_pred[mask] = paddle.full(
                      [1],
                      encode_pan_id(
                          pred_class,
                          self.label_divisor,
                          ins_id=class_id_tracker[pred_class],
                      ),
                      dtype="int64",
                  )
  
              current_segment_id += 1
              ins_id_map[mask] = current_segment_id
  
      return ins_id_map, pan_pred
  
file_path: PaddleSeg/contrib/PanopticSeg/paddlepanseg/postprocessors/maskformer_pp.py
imports: from collections import Counter
  import paddle
  import paddle.nn.functional
  from paddlepanseg.cvlibs import build_info_dict, manager
  from paddlepanseg.utils import encode_pan_id
  from paddlepanseg.postprocessors.base_pp import Postprocessor
label_desc: Use image node_id 3 for calling the MaskFormerPostprocessor obj's underlying member method code with example usage: obj._panoptic_inference(mask_cls, mask_pred) and returns: ins_id_map,  pan_pred, ins_id_map,  pan_pred