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: Process gts and predictions when ``outfile_prefix`` is not set, gts
  are from dataset or a json file which is defined by ``ann_file``.
  
  Intermediate results, ``pq_stats``, are computed here and put into
  ``self.results``.
docstr_tok: ["Process","gts","and","predictions","when","``","outfile_prefix","``","is","not","set",",","gts","are","from","dataset","or","a","json","file","which","is","defined","by","``","ann_file","``",".","Intermediate","results",",","``","pq_stats","``",",","are","computed","here","and","put","into","``","self.results","``","."]
code: def _compute_batch_pq_stats(self, data_samples: Sequence[dict]):
      """Process gts and predictions when ``outfile_prefix`` is not set, gts
      are from dataset or a json file which is defined by ``ann_file``.
  
      Intermediate results, ``pq_stats``, are computed here and put into
      ``self.results``.
      """
      if self._coco_api is None:
          categories = dict()
          for id, name in enumerate(self.dataset_meta["classes"]):
              isthing = (
                  1 if name in self.dataset_meta["thing_classes"] else 0
              )
              categories[id] = {
                  "id": id,
                  "name": name,
                  "isthing": isthing,
              }
          label2cat = None
      else:
          categories = self.categories
          cat_ids = self._coco_api.get_cat_ids(
              cat_names=self.dataset_meta["classes"]
          )
          label2cat = {i: cat_id for i, cat_id in enumerate(cat_ids)}
  
      for data_sample in data_samples:
          # parse pred
          img_id = data_sample["img_id"]
          segm_file = osp.basename(data_sample["img_path"]).replace(
              ".jpg", ".png"
          )
          result = self._parse_predictions(
              pred=data_sample,
              img_id=img_id,
              segm_file=segm_file,
              label2cat=label2cat,
          )
  
          # parse gt
          gt = dict()
          gt["image_id"] = img_id
          gt["width"] = data_sample["ori_shape"][1]
          gt["height"] = data_sample["ori_shape"][0]
          gt["file_name"] = segm_file
  
          if self._coco_api is None:
              # get segments_info from data_sample
              seg_map_path = osp.join(self.seg_prefix, segm_file)
              pan_png = mmcv.imread(seg_map_path).squeeze()
              pan_png = pan_png[:, :, ::-1]
              pan_png = rgb2id(pan_png)
              segments_info = []
  
              for segment_info in data_sample["segments_info"]:
                  id = segment_info["id"]
                  label = segment_info["category"]
                  mask = pan_png == id
                  isthing = categories[label]["isthing"]
                  if isthing:
                      iscrowd = 1 if not segment_info["is_thing"] else 0
                  else:
                      iscrowd = 0
  
                  new_segment_info = {
                      "id": id,
                      "category_id": label,
                      "isthing": isthing,
                      "iscrowd": iscrowd,
                      "area": mask.sum(),
                  }
                  segments_info.append(new_segment_info)
          else:
              # get segments_info from annotation file
              segments_info = self._coco_api.imgToAnns[img_id]
  
          gt["segments_info"] = segments_info
  
          pq_stats = pq_compute_single_core(
              proc_id=0,
              annotation_set=[(gt, result)],
              gt_folder=self.seg_prefix,
              pred_folder=self.seg_out_dir,
              categories=categories,
              backend_args=self.backend_args,
          )
  
          self.results.append(pq_stats)
  
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 6 for calling the CocoPanopticMetric obj's underlying member method code with example usage: obj._compute_batch_pq_stats(data_samples) without return types