class_docstr: Abstract class to calculate average precision and recall for various vision tasks.
  
  Parameters
  ----------
  max_dets: Union[List[int], Tuple[int]], default: [1, 10, 100]
      Maximum number of detections per class.
  area_range: tuple, default: (32**2, 96**2)
      Slices for small/medium/large buckets.
  return_option: str, default: 'ap'
      ap: ap only, ar: ar only, None: all (not ignite compliant).
  average: str, default: none
      The method for averaging over the classes. If none, returns the result per class.
  iou_range: Tuple[float, float, float], default: (0.5, 0.95, 10)
      The closed range of the iou values (min, max (including), number of points)
class_docstr_tok: ["Abstract","class","to","calculate","average","precision","and","recall","for","various","vision","tasks",".","Parameters","--","--","--","--","--","max_dets",":","Union","[","List","[","int","]",",","Tuple","[","int","]","]",",","default",":","[","1",",","10",",","100","]","Maximum","number","of","detections","per","class",".","area_range",":","tuple",",","default",":","(","32","*","*","2",",","96","*","*","2",")","Slices","for","small\/medium\/large","buckets",".","return_option",":","str",",","default",":","'ap'","ap",":","ap","only",",","ar",":","ar","only",",","None",":","all","(","not","ignite","compliant",")",".","average",":","str",",","default",":","none","The","method","for","averaging","over","the","classes",".","If","none",",","returns","the","result","per","class",".","iou_range",":","Tuple","[","float",",","float",",","float","]",",","default",":","(","0.5",",","0.95",",","10",")","The","closed","range","of","the","iou","values","(","min",",","max","(","including",")",",","number","of","points",")"]
docstr: Evaluate image.
docstr_tok: ["Evaluate","image","."]
code: def _evaluate_image(self, detections, ground_truths, ious):
      """Evaluate image."""
      # Sort detections by decreasing confidence
      confidences = self.get_confidences(detections)
      areas = self.get_detection_areas(detections)
      sorted_confidence_ids = np.argsort(confidences, kind="stable")[
          ::-1
      ]
      orig_ious = ious
      orig_gt = ground_truths
      ground_truth_area = np.array(self.get_labels_areas(ground_truths))
  
      scores = {}
      matched = {}
      n_gts = {}
      for top_n_detections in self.max_detections_per_class:
          for area_size in self.area_ranges_names:
              # sort list of dts and chop by max dets
              top_detections_idx = sorted_confidence_ids[
                  :top_n_detections
              ]
              ious = orig_ious[top_detections_idx]
              ground_truth_to_ignore = [
                  self._is_ignore_area(gt_area, area_size)
                  for gt_area in ground_truth_area
              ]
  
              # sort gts by ignore last
              gt_sort = np.argsort(
                  ground_truth_to_ignore, kind="stable"
              )
              ground_truths = [orig_gt[idx] for idx in gt_sort]
              ground_truth_to_ignore = [
                  ground_truth_to_ignore[idx] for idx in gt_sort
              ]
  
              ious = ious[:, gt_sort]
              for min_iou in self.iou_thresholds:
                  detection_matches = self._get_best_matches(
                      top_detections_idx,
                      min_iou,
                      ground_truths,
                      ground_truth_to_ignore,
                      ious,
                  )
  
                  # generate ignore list for dts
                  detections_to_ignore = [
                      ground_truth_to_ignore[detection_matches[d_idx]]
                      if d_idx in detection_matches
                      else self._is_ignore_area(
                          areas[real_index], area_size
                      )
                      for d_idx, real_index in enumerate(
                          top_detections_idx
                      )
                  ]
  
                  # get score for non-ignored dts
                  scores[(area_size, top_n_detections, min_iou)] = [
                      confidences[real_index]
                      for d_idx, real_index in enumerate(
                          top_detections_idx
                      )
                      if not detections_to_ignore[d_idx]
                  ]
                  matched[(area_size, top_n_detections, min_iou)] = [
                      d_idx in detection_matches
                      for d_idx, real_index in enumerate(
                          top_detections_idx
                      )
                      if not detections_to_ignore[d_idx]
                  ]
                  n_gts[(area_size, top_n_detections, min_iou)] = len(
                      [
                          g_idx
                          for g_idx in range(len(ground_truths))
                          if not ground_truth_to_ignore[g_idx]
                      ]
                  )
      return {"scores": scores, "matched": matched, "NP": n_gts}
  
imports: import warnings
  from collections import defaultdict
  from typing import List, Optional, Tuple, Union
  import numpy
  from ignite.metrics import Metric
  from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.vision.metrics_utils.metric_mixin import MetricMixin, ObjectDetectionMetricMixin
label_desc: Use image node_id 6 for calling the AveragePrecisionRecall obj's underlying member method code with example usage: obj._evaluate_image(detections, ground_truths, ious) and returns: dict