code: def process_batch(detections, labels, iouv):
      """
      Return correct predictions matrix. Both sets of boxes are in (x1, y1, x2, y2) format.
      Arguments:
          detections (Array[N, 6]), x1, y1, x2, y2, conf, class
          labels (Array[M, 5]), class, x1, y1, x2, y2
      Returns:
          correct (Array[N, 10]), for 10 IoU levels
      """
      detections[:, [1, 3]] = torch.clamp(
          detections[:, [1, 3]], 0.0, 416
      )
      detections[:, [2, 4]] = torch.clamp(
          detections[:, [2, 4]], 0.0, 416
      )
  
      correct = torch.zeros(
          detections.shape[0],
          iouv.shape[0],
          dtype=torch.bool,
          device=iouv.device,
      )
      iou = box_iou(labels[:, 1:], detections[:, 1:5])
      x = torch.where(
          (iou >= iouv[0]) & (labels[:, 0:1] == detections[:, 7])
      )  # IoU above threshold and classes match
      if x[0].shape[0]:
          matches = (
              torch.cat(
                  (torch.stack(x, 1), iou[x[0], x[1]][:, None]), 1
              )
              .cpu()
              .numpy()
          )  # [label, detection, iou]
          if x[0].shape[0] > 1:
              matches = matches[matches[:, 2].argsort()[::-1]]
              matches = matches[
                  np.unique(matches[:, 1], return_index=True)[1]
              ]
              matches = matches[
                  np.unique(matches[:, 0], return_index=True)[1]
              ]
          matches = torch.Tensor(matches).to(iouv.device)
          correct[matches[:, 1].long()] = matches[:, 2:3] >= iouv
      return correct
  
file_path: ImageAI/imageai/Detection/Custom/yolo/validate.py
imports: import os
  import numpy
  import torch
  from torchvision.ops import box_iou
  from ....yolov3.utils import get_predictions
  from .metric import ap_per_class
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: process_batch(detections, labels, iouv) and returns: correct