docstr: Compute average precision
  
  Args:
      dataset_statistics (dict): computed statistics over dataset
  
          - `counts`: Number of thresholds, Number recall thresholds, Number of classes, Number of max
            detection thresholds
          - `recall`: Computed recall values [num_iou_th, num_classes, num_max_detections]
          - `precision`: Precision values at specified recall thresholds
            [num_iou_th, num_recall_th, num_classes, num_max_detections]
          - `scores`: Scores corresponding to specified recall thresholds
            [num_iou_th, num_recall_th, num_classes, num_max_detections]
      iou_idx: index of IoU values to select for evaluation(if None, all values are used)
      cls_idx: class indices to select, if None all classes will be selected
      max_det_idx (int): index to select max detection threshold from data
  
  Returns:
      np.ndarray: AP value
docstr_tok: ["Compute","average","precision","Args",":","dataset_statistics","(","dict",")",":","computed","statistics","over","dataset","-","`","counts","`",":","Number","of","thresholds",",","Number","recall","thresholds",",","Number","of","classes",",","Number","of","max","detection","thresholds","-","`","recall","`",":","Computed","recall","values","[","num_iou_th",",","num_classes",",","num_max_detections","]","-","`","precision","`",":","Precision","values","at","specified","recall","thresholds","[","num_iou_th",",","num_recall_th",",","num_classes",",","num_max_detections","]","-","`","scores","`",":","Scores","corresponding","to","specified","recall","thresholds","[","num_iou_th",",","num_recall_th",",","num_classes",",","num_max_detections","]","iou_idx",":","index","of","IoU","values","to","select","for","evaluation","(","if","None",",","all","values","are","used",")","cls_idx",":","class","indices","to","select",",","if","None","all","classes","will","be","selected","max_det_idx","(","int",")",":","index","to","select","max","detection","threshold","from","data","Returns",":","np.ndarray",":","AP","value"]
code: def _select_ap(
      dataset_statistics: dict,
      iou_idx: int | list[int] | np.ndarray | None = None,
      cls_idx: int | Sequence[int] | None = None,
      max_det_idx: int = -1,
  ) -> float:
      """
      Compute average precision
  
      Args:
          dataset_statistics (dict): computed statistics over dataset
  
              - `counts`: Number of thresholds, Number recall thresholds, Number of classes, Number of max
                detection thresholds
              - `recall`: Computed recall values [num_iou_th, num_classes, num_max_detections]
              - `precision`: Precision values at specified recall thresholds
                [num_iou_th, num_recall_th, num_classes, num_max_detections]
              - `scores`: Scores corresponding to specified recall thresholds
                [num_iou_th, num_recall_th, num_classes, num_max_detections]
          iou_idx: index of IoU values to select for evaluation(if None, all values are used)
          cls_idx: class indices to select, if None all classes will be selected
          max_det_idx (int): index to select max detection threshold from data
  
      Returns:
          np.ndarray: AP value
      """
      prec = dataset_statistics["precision"]
      if iou_idx is not None:
          prec = prec[iou_idx]
      if cls_idx is not None:
          prec = prec[..., cls_idx, :]
      prec = prec[..., max_det_idx]
      return float(np.mean(prec))
  
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 8 for calling the COCOMetric obj's underlying member method code with example usage: obj._select_ap(dataset_statistics, iou_idx, cls_idx, max_det_idx) and returns: float