class_docstr: Evaluate AR for object proposals, AP for instance detection/segmentation, AP
  for keypoint detection outputs using COCO's metrics.
  See http://cocodataset.org/#detection-eval and
  http://cocodataset.org/#keypoints-eval to understand its metrics.
  
  In addition to COCO, this evaluator is able to support any bounding box detection,
  instance segmentation, or keypoint detection dataset.
class_docstr_tok: ["Evaluate","AR","for","object","proposals",",","AP","for","instance","detection\/segmentation",",","AP","for","keypoint","detection","outputs","using","COCO","'s","metrics",".","See","http",":","\/\/cocodataset.org\/","#","detection-eval","and","http",":","\/\/cocodataset.org\/","#","keypoints-eval","to","understand","its","metrics",".","In","addition","to","COCO",",","this","evaluator","is","able","to","support","any","bounding","box","detection",",","instance","segmentation",",","or","keypoint","detection","dataset","."]
docstr: Args:
      dataset_name (str): name of the dataset to be evaluated.
          It must have either the following corresponding metadata:
  
              "json_file": the path to the COCO format annotation
  
          Or it must be in detectron2's standard dataset format
          so it can be converted to COCO format automatically.
      cfg (CfgNode): config instance
      distributed (True): if True, will collect results from all ranks and run evaluation
          in the main process.
          Otherwise, will evaluate the results in the current process.
      output_dir (str): optional, an output directory to dump all
          results predicted on the dataset. The dump contains two files:
  
          1. "instance_predictions.pth" a file in torch serialization
             format that contains all the raw original predictions.
          2. "coco_instances_results.json" a json file in COCO's result
             format.
docstr_tok: ["Args",":","dataset_name","(","str",")",":","name","of","the","dataset","to","be","evaluated",".","It","must","have","either","the","following","corresponding","metadata",":","``","json_file","''",":","the","path","to","the","COCO","format","annotation","Or","it","must","be","in","detectron2","'s","standard","dataset","format","so","it","can","be","converted","to","COCO","format","automatically",".","cfg","(","CfgNode",")",":","config","instance","distributed","(","True",")",":","if","True",",","will","collect","results","from","all","ranks","and","run","evaluation","in","the","main","process",".","Otherwise",",","will","evaluate","the","results","in","the","current","process",".","output_dir","(","str",")",":","optional",",","an","output","directory","to","dump","all","results","predicted","on","the","dataset",".","The","dump","contains","two","files",":","1",".","``","instance_predictions.pth","''","a","file","in","torch","serialization","format","that","contains","all","the","raw","original","predictions",".","2",".","``","coco_instances_results.json","''","a","json","file","in","COCO","'s","result","format","."]
code: def __init__(self, dataset_name, cfg, distributed, output_dir=None):
      """
      Args:
          dataset_name (str): name of the dataset to be evaluated.
              It must have either the following corresponding metadata:
  
                  "json_file": the path to the COCO format annotation
  
              Or it must be in detectron2's standard dataset format
              so it can be converted to COCO format automatically.
          cfg (CfgNode): config instance
          distributed (True): if True, will collect results from all ranks and run evaluation
              in the main process.
              Otherwise, will evaluate the results in the current process.
          output_dir (str): optional, an output directory to dump all
              results predicted on the dataset. The dump contains two files:
  
              1. "instance_predictions.pth" a file in torch serialization
                 format that contains all the raw original predictions.
              2. "coco_instances_results.json" a json file in COCO's result
                 format.
      """
      try_import_pycocotools()
      from pycocotools.coco import COCO
  
      self._tasks = self._tasks_from_config(cfg)
      self._distributed = distributed
      self._output_dir = output_dir
  
      self._cpu_device = torch.device("cpu")
      self._logger = logging.getLogger(__name__)
  
      self._metadata = MetadataCatalog.get(dataset_name)
      if not hasattr(self._metadata, "json_file"):
          self._logger.info(
              f"'{dataset_name}' is not registered by `register_coco_instances`."
              " Therefore trying to convert it to COCO format ..."
          )
  
          cache_path = os.path.join(
              output_dir, f"{dataset_name}_coco_format.json"
          )
          self._metadata.json_file = cache_path
          convert_to_coco_json(dataset_name, cache_path)
  
      json_file = self._metadata.json_file
      with contextlib.redirect_stdout(io.StringIO()):
          self._coco_api = COCO(json_file)
  
      self._kpt_oks_sigmas = cfg.CONFIG.VAL.KEYPOINT_OKS_SIGMAS
      # Test set json files do not contain annotations (evaluation must be
      # performed using the COCO evaluation server).
      self._do_evaluation = "annotations" in self._coco_api.dataset
  
imports: import contextlib
  import copy
  import io
  import itertools
  import json
  import logging
  import os
  import pickle
  from collections import OrderedDict
  import numpy
  import torch
  import pandas
  from ..None import comm
  from ...data.registry.catalog import MetadataCatalog
  from ...data.registry.mscoco import convert_to_coco_json
  from ...data.structures import Boxes, BoxMode, pairwise_iou
  from ...data.detection.detection_utils import try_import_pycocotools
label_desc: Use image node_id 1 to create a new COCOEvaluator object  with example: obj = COCOEvaluator(dataset_name, cfg, distributed, output_dir)