code: def voc_ap(recall, precision):
      """ap = voc_ap(recall, precision)
      Compute PASCAL VOC AP given precision and recall.
      recall and precision contain one element per detected instance,
      ordered by certainty (most certain element first)
      (see here for an explanation https://github.com/rafaelpadilla/Object-Detection-Metrics)
      """
      # correct AP calculation
      # first append sentinel values at the end
      mrec = np.concatenate(([0.0], recall, [1.0]))
      mpre = np.concatenate(([0.0], precision, [0.0]))
  
      # compute the precision envelope
      for i in range(mpre.size - 1, 0, -1):
          mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i])
  
      # to calculate area under PR curve, look for points
      # where X axis (recall) changes value
      i = np.where(mrec[1:] != mrec[:-1])[0]
  
      # and sum (\Delta recall) * prec
      ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1])
      return ap
  
imports: import numpy
  from multiprocessing import Pool
  from torch_points3d.utils.box_utils import box3d_iou
  from torch_points3d.datasets.object_detection.box_data import BoxData
label_desc: Use image node_id 1 for calling a global function with example usage: voc_ap(recall, precision) and returns: ap