class_docstr: COCO panoptic segmentation evaluation metric.
  
  Evaluate PQ, SQ RQ for panoptic segmentation tasks. Please refer to
  https://cocodataset.org/#panoptic-eval for more details.
  
  Args:
      ann_file (str, optional): Path to the coco format annotation file.
          If not specified, ground truth annotations from the dataset will
          be converted to coco format. Defaults to None.
      seg_prefix (str, optional): Path to the directory which contains the
          coco panoptic segmentation mask. It should be specified when
          evaluate. Defaults to None.
      classwise (bool): Whether to evaluate the metric class-wise.
          Defaults to False.
      outfile_prefix (str, optional): The prefix of json files. It includes
          the file path and the prefix of filename, e.g., "a/b/prefix".
          If not specified, a temp file will be created.
          It should be specified when format_only is True. Defaults to None.
      format_only (bool): Format the output results without perform
          evaluation. It is useful when you want to format the result
          to a specific format and submit it to the test server.
          Defaults to False.
      nproc (int): Number of processes for panoptic quality computing.
          Defaults to 32. When ``nproc`` exceeds the number of cpu cores,
          the number of cpu cores is used.
      file_client_args (dict, optional): Arguments to instantiate the
          corresponding backend in mmdet <= 3.0.0rc6. Defaults to None.
      backend_args (dict, optional): Arguments to instantiate the
          corresponding backend. Defaults to None.
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Defaults to None.
class_docstr_tok: ["COCO","panoptic","segmentation","evaluation","metric",".","Evaluate","PQ",",","SQ","RQ","for","panoptic","segmentation","tasks",".","Please","refer","to","https",":","\/\/cocodataset.org\/","#","panoptic-eval","for","more","details",".","Args",":","ann_file","(","str",",","optional",")",":","Path","to","the","coco","format","annotation","file",".","If","not","specified",",","ground","truth","annotations","from","the","dataset","will","be","converted","to","coco","format",".","Defaults","to","None",".","seg_prefix","(","str",",","optional",")",":","Path","to","the","directory","which","contains","the","coco","panoptic","segmentation","mask",".","It","should","be","specified","when","evaluate",".","Defaults","to","None",".","classwise","(","bool",")",":","Whether","to","evaluate","the","metric","class-wise",".","Defaults","to","False",".","outfile_prefix","(","str",",","optional",")",":","The","prefix","of","json","files",".","It","includes","the","file","path","and","the","prefix","of","filename",",","e.g.",",","``","a\/b\/prefix","''",".","If","not","specified",",","a","temp","file","will","be","created",".","It","should","be","specified","when","format_only","is","True",".","Defaults","to","None",".","format_only","(","bool",")",":","Format","the","output","results","without","perform","evaluation",".","It","is","useful","when","you","want","to","format","the","result","to","a","specific","format","and","submit","it","to","the","test","server",".","Defaults","to","False",".","nproc","(","int",")",":","Number","of","processes","for","panoptic","quality","computing",".","Defaults","to","32",".","When","``","nproc","``","exceeds","the","number","of","cpu","cores",",","the","number","of","cpu","cores","is","used",".","file_client_args","(","dict",",","optional",")",":","Arguments","to","instantiate","the","corresponding","backend","in","mmdet","<","=","3.0.0rc6",".","Defaults","to","None",".","backend_args","(","dict",",","optional",")",":","Arguments","to","instantiate","the","corresponding","backend",".","Defaults","to","None",".","collect_device","(","str",")",":","Device","name","used","for","collecting","results","from","different","ranks","during","distributed","training",".","Must","be","'cpu","'","or","'gpu","'",".","Defaults","to","'cpu","'",".","prefix","(","str",",","optional",")",":","The","prefix","that","will","be","added","in","the","metric","names","to","disambiguate","homonymous","metrics","of","different","evaluators",".","If","prefix","is","not","provided","in","the","argument",",","self.default_prefix","will","be","used","instead",".","Defaults","to","None","."]
docstr: Parse panoptic segmentation predictions.
  
  Args:
      pred (dict): Panoptic segmentation predictions.
      img_id (int): Image id.
      segm_file (str): Segmentation file name.
      label2cat (dict): Mapping from label to category id.
          Defaults to None.
  
  Returns:
      dict: Parsed predictions.
docstr_tok: ["Parse","panoptic","segmentation","predictions",".","Args",":","pred","(","dict",")",":","Panoptic","segmentation","predictions",".","img_id","(","int",")",":","Image","id",".","segm_file","(","str",")",":","Segmentation","file","name",".","label2cat","(","dict",")",":","Mapping","from","label","to","category","id",".","Defaults","to","None",".","Returns",":","dict",":","Parsed","predictions","."]
code: def _parse_predictions(
      self, pred: dict, img_id: int, segm_file: str, label2cat=None
  ) -> dict:
      """Parse panoptic segmentation predictions.
  
      Args:
          pred (dict): Panoptic segmentation predictions.
          img_id (int): Image id.
          segm_file (str): Segmentation file name.
          label2cat (dict): Mapping from label to category id.
              Defaults to None.
  
      Returns:
          dict: Parsed predictions.
      """
      result = dict()
      result["img_id"] = img_id
      # shape (1, H, W) -> (H, W)
      pan = pred["pred_panoptic_seg"]["sem_seg"].cpu().numpy()[0]
      ignore_index = pred["pred_panoptic_seg"].get(
          "ignore_index", len(self.dataset_meta["classes"])
      )
      pan_labels = np.unique(pan)
      segments_info = []
      for pan_label in pan_labels:
          sem_label = pan_label % INSTANCE_OFFSET
          # We reserve the length of dataset_meta['classes']
          # and ignore_index for VOID label
          if (
              sem_label == len(self.dataset_meta["classes"])
              or sem_label == ignore_index
          ):
              continue
          mask = pan == pan_label
          area = mask.sum()
          segments_info.append(
              {
                  "id": int(pan_label),
                  # when ann_file provided, sem_label should be cat_id, otherwise
                  # sem_label should be a continuous id, not the cat_id
                  # defined in dataset
                  "category_id": label2cat[sem_label]
                  if label2cat
                  else sem_label,
                  "area": int(area),
              }
          )
      # evaluation script uses 0 for VOID label.
      pan[
          pan % INSTANCE_OFFSET == len(self.dataset_meta["classes"])
      ] = VOID
      pan[pan % INSTANCE_OFFSET == ignore_index] = VOID
  
      pan = id2rgb(pan).astype(np.uint8)
      mmcv.imwrite(
          pan[:, :, ::-1], osp.join(self.seg_out_dir, segm_file)
      )
      result = {
          "image_id": img_id,
          "segments_info": segments_info,
          "file_name": segm_file,
      }
  
      return result
  
imports: import datetime
  import itertools
  import os.path
  import tempfile
  from typing import Dict, Optional, Sequence, Tuple, Union
  import mmcv
  import numpy
  from mmengine.evaluator import BaseMetric
  from mmengine.fileio import dump, get_local_path, load
  from mmengine.logging import MMLogger, print_log
  from terminaltables import AsciiTable
  from mmdet.datasets.api_wrappers import COCOPanoptic
  from mmdet.registry import METRICS
  from ..functional import INSTANCE_OFFSET, pq_compute_multi_core, pq_compute_single_core
label_desc: Use image node_id 5 for calling the CocoPanopticMetric obj's underlying member method code with example usage: obj._parse_predictions(pred, img_id, segm_file, label2cat) and returns: result