code: def _compute_pr_curves(matches, classes=None):
      if classes is None:
          _classes = set()
  
      class_matches = {}
  
      # For crowds, GTs are only counted once
      counted_gts = []
  
      # Sort matches
      for m in matches:
          # m = (gt_label, pred_label, iou, confidence, gt.id, pred.id)
          if classes is None:
              _classes.add(m[0])
              _classes.add(m[1])
  
          c = m[0] if m[0] is not None else m[1]
  
          if c not in class_matches:
              class_matches[c] = {
                  "tp": [],
                  "fp": [],
                  "num_gt": 0,
              }
  
          if m[0] == m[1]:
              class_matches[c]["tp"].append(m)
          elif m[1]:
              class_matches[c]["fp"].append(m)
  
          if m[0] and m[4] not in counted_gts:
              class_matches[c]["num_gt"] += 1
              counted_gts.append(m[4])
  
      if classes is None:
          _classes.discard(None)
          classes = sorted(_classes)
  
      # Compute precision-recall array
      precision = {}
      recall = {}
      thresholds = {}
      for c in class_matches.keys():
          tp = class_matches[c]["tp"]
          fp = class_matches[c]["fp"]
          num_gt = class_matches[c]["num_gt"]
          if num_gt == 0:
              continue
  
          tp_fp = np.array([1] * len(tp) + [0] * len(fp))
          confs = np.array([p[3] for p in tp] + [p[3] for p in fp])
  
          inds = np.argsort(-confs)
          tp_fp = tp_fp[inds]
          confs = confs[inds]
  
          tp_sum = np.cumsum(tp_fp).astype(dtype=float)
          total = np.arange(1, len(tp_fp) + 1).astype(dtype=float)
  
          pre = tp_sum / total
          rec = tp_sum / num_gt
  
          pre0 = pre[0] if pre.size > 0 else 1
          conf0 = max(1, confs[0]) if confs.size > 0 else 1
  
          pre = np.concatenate([[pre0], pre, [0]])
          confs = np.concatenate([[conf0], confs, [0]])
          rec = np.concatenate([[0], rec, [1]])
  
          # Ensure precision is nondecreasing
          for i in range(len(pre) - 1, 0, -1):
              if pre[i] > pre[i - 1]:
                  pre[i - 1] = pre[i]
  
          precision[c] = pre
          recall[c] = rec
          thresholds[c] = confs
  
      return precision, recall, thresholds, classes
  
imports: from collections import defaultdict
  from copy import deepcopy
  import numpy
  import fiftyone.core.plots
  import fiftyone.utils.iou
  from .detection import DetectionEvaluation, DetectionEvaluationConfig, DetectionResults
label_desc: Use image node_id 6 for calling a global function with example usage: _compute_pr_curves(matches, classes) and returns: precision,  recall,  thresholds,  classes