docstr: Compute AP metrics
  
  Args:
      dataset_statistics (list[dict[int, dict[str, np.ndarray]]]): list with result s per image (in list)
          per category (dict). Inner dict contains multiple results obtained by :func:`box_matching_batch`.
  
          - `dtMatches`: matched detections [T, D], where T = number of
            thresholds, D = number of detections
          - `gtMatches`: matched ground truth boxes [T, G], where T = number
            of thresholds, G = number of ground truth
          - `dtScores`: prediction scores [D] detection scores
          - `gtIgnore`: ground truth boxes which should be ignored
            [G] indicate whether ground truth should be ignored
          - `dtIgnore`: detections which should be ignored [T, D],
            indicate which detections should be ignored
docstr_tok: ["Compute","AP","metrics","Args",":","dataset_statistics","(","list","[","dict","[","int",",","dict","[","str",",","np.ndarray","]","]","]",")",":","list","with","result","s","per","image","(","in","list",")","per","category","(","dict",")",".","Inner","dict","contains","multiple","results","obtained","by",":","func",":","`","box_matching_batch","`",".","-","`","dtMatches","`",":","matched","detections","[","T",",","D","]",",","where","T","=","number","of","thresholds",",","D","=","number","of","detections","-","`","gtMatches","`",":","matched","ground","truth","boxes","[","T",",","G","]",",","where","T","=","number","of","thresholds",",","G","=","number","of","ground","truth","-","`","dtScores","`",":","prediction","scores","[","D","]","detection","scores","-","`","gtIgnore","`",":","ground","truth","boxes","which","should","be","ignored","[","G","]","indicate","whether","ground","truth","should","be","ignored","-","`","dtIgnore","`",":","detections","which","should","be","ignored","[","T",",","D","]",",","indicate","which","detections","should","be","ignored"]
code: def _compute_ap(
      self, dataset_statistics: dict[str, np.ndarray | list]
  ) -> dict[str, float]:
      """
      Compute AP metrics
  
      Args:
          dataset_statistics (list[dict[int, dict[str, np.ndarray]]]): list with result s per image (in list)
              per category (dict). Inner dict contains multiple results obtained by :func:`box_matching_batch`.
  
              - `dtMatches`: matched detections [T, D], where T = number of
                thresholds, D = number of detections
              - `gtMatches`: matched ground truth boxes [T, G], where T = number
                of thresholds, G = number of ground truth
              - `dtScores`: prediction scores [D] detection scores
              - `gtIgnore`: ground truth boxes which should be ignored
                [G] indicate whether ground truth should be ignored
              - `dtIgnore`: detections which should be ignored [T, D],
                indicate which detections should be ignored
      """
      results = {}
      if self.iou_range:  # mAP
          key = (
              f"mAP_IoU_{self.iou_range[0]:.2f}_{self.iou_range[1]:.2f}_{self.iou_range[2]:.2f}_"
              f"MaxDet_{self.max_detections[-1]}"
          )
          results[key] = self._select_ap(
              dataset_statistics,
              iou_idx=self.iou_range_idx,
              max_det_idx=-1,
          )
  
          if self.per_class:
              for cls_idx, cls_str in enumerate(
                  self.classes
              ):  # per class results
                  key = (
                      f"{cls_str}_"
                      f"mAP_IoU_{self.iou_range[0]:.2f}_{self.iou_range[1]:.2f}_{self.iou_range[2]:.2f}_"
                      f"MaxDet_{self.max_detections[-1]}"
                  )
                  results[key] = self._select_ap(
                      dataset_statistics,
                      iou_idx=self.iou_range_idx,
                      cls_idx=cls_idx,
                      max_det_idx=-1,
                  )
  
      for idx in self.iou_list_idx:  # AP@IoU
          key = f"AP_IoU_{self.iou_thresholds[idx]:.2f}_MaxDet_{self.max_detections[-1]}"
          results[key] = self._select_ap(
              dataset_statistics, iou_idx=[idx], max_det_idx=-1
          )
  
          if self.per_class:
              for cls_idx, cls_str in enumerate(
                  self.classes
              ):  # per class results
                  key = (
                      f"{cls_str}_"
                      f"AP_IoU_{self.iou_thresholds[idx]:.2f}_"
                      f"MaxDet_{self.max_detections[-1]}"
                  )
                  results[key] = self._select_ap(
                      dataset_statistics,
                      iou_idx=[idx],
                      cls_idx=cls_idx,
                      max_det_idx=-1,
                  )
      return results
  
file_path: MONAI/monai/apps/detection/metrics/coco.py
imports: from __future__ import annotations
  import logging
  import time
  from collections.abc import Sequence
  from typing import Any
  import numpy
label_desc: Use image node_id 6 for calling the COCOMetric obj's underlying member method code with example usage: obj._compute_ap(dataset_statistics) and returns: results