code: def prefilter_boxes(boxes, scores, labels, weights, thr):
      new_boxes = dict()
  
      for t in range(len(boxes)):
          if len(boxes[t]) != len(scores[t]):
              print(
                  "Error. Length of boxes arrays not equal to "
                  "length of scores array: {} != {}".format(
                      len(boxes[t]), len(scores[t])
                  )
              )
              exit()
  
          if len(boxes[t]) != len(labels[t]):
              print(
                  "Error. Length of boxes arrays not equal to "
                  "length of labels array: {} != {}".format(
                      len(boxes[t]), len(labels[t])
                  )
              )
              exit()
  
          for j in range(len(boxes[t])):
              score = scores[t][j]
              if score < thr:
                  continue
              label = int(labels[t][j])
              box_part = boxes[t][j]
              x1 = float(box_part[0])
              y1 = float(box_part[1])
              x2 = float(box_part[2])
              y2 = float(box_part[3])
  
              # Box data checks
              if x2 < x1:
                  warnings.warn("X2 < X1 value in box. Swap them.")
                  x1, x2 = x2, x1
              if y2 < y1:
                  warnings.warn("Y2 < Y1 value in box. Swap them.")
                  y1, y2 = y2, y1
              if (x2 - x1) * (y2 - y1) == 0.0:
                  warnings.warn(
                      "Zero area box skipped: {}.".format(box_part)
                  )
                  continue
  
              # [label, score, weight, model index, x1, y1, x2, y2]
              b = [
                  int(label),
                  float(score) * weights[t],
                  weights[t],
                  t,
                  x1,
                  y1,
                  x2,
                  y2,
              ]
  
              if label not in new_boxes:
                  new_boxes[label] = []
              new_boxes[label].append(b)
  
      # Sort each list in dict by score and transform it to numpy array
      for k in new_boxes:
          current_boxes = np.array(new_boxes[k])
          new_boxes[k] = current_boxes[
              current_boxes[:, 1].argsort()[::-1]
          ]
  
      return new_boxes
  
file_path: mmdetection/mmdet/models/utils/wbf.py
imports: import warnings
  from typing import Tuple
  import numpy
  import torch
  from torch import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: prefilter_boxes(boxes, scores, labels, weights, thr) and returns: new_boxes