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","."]
code: def __init__(
      self,
      ann_file: Optional[str] = None,
      seg_prefix: Optional[str] = None,
      classwise: bool = False,
      format_only: bool = False,
      outfile_prefix: Optional[str] = None,
      nproc: int = 32,
      file_client_args: dict = None,
      backend_args: dict = None,
      collect_device: str = "cpu",
      prefix: Optional[str] = None,
  ) -> None:
      if panopticapi is None:
          raise RuntimeError(
              "panopticapi is not installed, please install it by: "
              "pip install git+https://github.com/cocodataset/"
              "panopticapi.git."
          )
  
      super().__init__(collect_device=collect_device, prefix=prefix)
      self.classwise = classwise
      self.format_only = format_only
      if self.format_only:
          assert (
              outfile_prefix is not None
          ), "outfile_prefix must be not"
          "None when format_only is True, otherwise the result files will"
          "be saved to a temp directory which will be cleaned up at the end."
  
      self.tmp_dir = None
      # outfile_prefix should be a prefix of a path which points to a shared
      # storage when train or test with multi nodes.
      self.outfile_prefix = outfile_prefix
      if outfile_prefix is None:
          self.tmp_dir = tempfile.TemporaryDirectory()
          self.outfile_prefix = osp.join(self.tmp_dir.name, "results")
      # the directory to save predicted panoptic segmentation mask
      self.seg_out_dir = f"{self.outfile_prefix}.panoptic"
      self.nproc = nproc
      self.seg_prefix = seg_prefix
  
      self.cat_ids = None
      self.cat2label = None
  
      self.backend_args = backend_args
      if file_client_args is not None:
          raise RuntimeError(
              "The `file_client_args` is deprecated, "
              "please use `backend_args` instead, please refer to"
              "https://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py"  # noqa: E501
          )
  
      if ann_file:
          with get_local_path(
              ann_file, backend_args=self.backend_args
          ) as local_path:
              self._coco_api = COCOPanoptic(local_path)
          self.categories = self._coco_api.cats
      else:
          self._coco_api = None
          self.categories = None
  
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 1 to create a new CocoPanopticMetric object from inherited base classes: BaseMetric with example: obj = CocoPanopticMetric(ann_file, seg_prefix, classwise, format_only, outfile_prefix, nproc, file_client_args, backend_args, collect_device, prefix)