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: Dump the panoptic results to a COCO style json file and a directory.
  
  Args:
      results (Sequence[dict]): Testing results of the dataset.
      outfile_prefix (str): The filename prefix of the json files and the
          directory.
  
  Returns:
      Tuple[str, str]: The json file and the directory which contains                 panoptic segmentation masks. The filename of the json is
          "somepath/xxx.panoptic.json" and name of the directory is
          "somepath/xxx.panoptic".
docstr_tok: ["Dump","the","panoptic","results","to","a","COCO","style","json","file","and","a","directory",".","Args",":","results","(","Sequence","[","dict","]",")",":","Testing","results","of","the","dataset",".","outfile_prefix","(","str",")",":","The","filename","prefix","of","the","json","files","and","the","directory",".","Returns",":","Tuple","[","str",",","str","]",":","The","json","file","and","the","directory","which","contains","panoptic","segmentation","masks",".","The","filename","of","the","json","is","``","somepath\/xxx.panoptic.json","''","and","name","of","the","directory","is","``","somepath\/xxx.panoptic","''","."]
code: def result2json(
      self, results: Sequence[dict], outfile_prefix: str
  ) -> Tuple[str, str]:
      """Dump the panoptic results to a COCO style json file and a directory.
  
          Args:
              results (Sequence[dict]): Testing results of the dataset.
              outfile_prefix (str): The filename prefix of the json files and the
                  directory.
  
          Returns:
              Tuple[str, str]: The json file and the directory which contains \
                  panoptic segmentation masks. The filename of the json is
                  "somepath/xxx.panoptic.json" and name of the directory is
                  "somepath/xxx.panoptic".
          """
      label2cat = dict((v, k) for (k, v) in self.cat2label.items())
      pred_annotations = []
      for idx in range(len(results)):
          result = results[idx]
          for segment_info in result["segments_info"]:
              sem_label = segment_info["category_id"]
              # convert sem_label to json label
              cat_id = label2cat[sem_label]
              segment_info["category_id"] = label2cat[sem_label]
              is_thing = self.categories[cat_id]["isthing"]
              segment_info["isthing"] = is_thing
          pred_annotations.append(result)
      pan_json_results = dict(annotations=pred_annotations)
      json_filename = f"{outfile_prefix}.panoptic.json"
      dump(pan_json_results, json_filename)
      return json_filename, (
          self.seg_out_dir
          if self.tmp_dir is None
          else tempfile.gettempdir()
      )
  
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 4 for calling the CocoPanopticMetric obj's underlying member method code with example usage: obj.result2json(results, outfile_prefix) and returns: json_filename,  unknown