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",")"]
code: def _compute_ap_recall(
      self, scores, matched, n_positives, recall_thresholds=None
  ):
      if n_positives == 0:
          return -1, -1
  
      # by default evaluate on 101 recall levels
      if recall_thresholds is None:
          recall_thresholds = np.linspace(
              0.0,
              1.00,
              int(np.round((1.00 - 0.0) / 0.01)) + 1,
              endpoint=True,
          )
  
      # sort in descending score order
      inds = np.argsort(-scores, kind="mergesort")
  
      scores = scores[inds]
      matched = matched[inds]
  
      if len(matched):
          tp = np.cumsum(matched)
          fp = np.cumsum(~matched)
          rc = tp / n_positives
          pr = tp / (tp + fp + np.spacing(1))
  
          # make precision monotonically decreasing
          i_pr = np.maximum.accumulate(pr[::-1])[::-1]
  
          rec_idx = np.searchsorted(rc, recall_thresholds, side="left")
  
          # get interpolated precision values at the evaluation thresholds
          i_pr = np.array(
              [i_pr[r] if r < len(i_pr) else 0 for r in rec_idx]
          )
  
          return np.mean(i_pr), rc[-1]
      return 0, 0
  
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 8 for calling the AveragePrecisionRecall obj's underlying member method code with example usage: obj._compute_ap_recall(scores, matched, n_positives, recall_thresholds) and returns: int,  int, unknown,  unknown, np,  rc