code: def weighted_boxes_fusion(
      bboxes_list: list,
      scores_list: list,
      labels_list: list,
      weights: list = None,
      iou_thr: float = 0.55,
      skip_box_thr: float = 0.0,
      conf_type: str = "avg",
      allows_overflow: bool = False,
  ) -> Tuple[Tensor, Tensor, Tensor]:
      """weighted boxes fusion <https://arxiv.org/abs/1910.13302> is a method for
      fusing predictions from different object detection models, which utilizes
      confidence scores of all proposed bounding boxes to construct averaged
      boxes.
  
      Args:
          bboxes_list(list): list of boxes predictions from each model,
                                      each box is 4 numbers.
          scores_list(list): list of scores for each model
          labels_list(list): list of labels for each model
          weights: list of weights for each model.
                  Default: None, which means weight == 1 for each model
          iou_thr: IoU value for boxes to be a match
          skip_box_thr: exclude boxes with score lower than this variable.
          conf_type: how to calculate confidence in weighted boxes.
              'avg': average value,
              'max': maximum value,
              'box_and_model_avg': box and model wise hybrid weighted average,
              'absent_model_aware_avg': weighted average that takes into
                              account the absent model.
          allows_overflow: false if we want confidence score not exceed 1.0.
  
      Returns:
          bboxes(Tensor): boxes coordinates (Order of boxes: x1, y1, x2, y2).
          scores(Tensor): confidence scores
          labels(Tensor): boxes labels
      """
  
      if weights is None:
          weights = np.ones(len(bboxes_list))
      if len(weights) != len(bboxes_list):
          print(
              "Warning: incorrect number of weights {}. Must be: "
              "{}. Set weights equal to 1.".format(
                  len(weights), len(bboxes_list)
              )
          )
          weights = np.ones(len(bboxes_list))
      weights = np.array(weights)
  
      if conf_type not in [
          "avg",
          "max",
          "box_and_model_avg",
          "absent_model_aware_avg",
      ]:
          print(
              'Unknown conf_type: {}. Must be "avg", '
              '"max" or "box_and_model_avg", '
              'or "absent_model_aware_avg"'.format(conf_type)
          )
          exit()
  
      filtered_boxes = prefilter_boxes(
          bboxes_list, scores_list, labels_list, weights, skip_box_thr
      )
      if len(filtered_boxes) == 0:
          return torch.Tensor(), torch.Tensor(), torch.Tensor()
  
      overall_boxes = []
  
      for label in filtered_boxes:
          boxes = filtered_boxes[label]
          new_boxes = []
          weighted_boxes = np.empty((0, 8))
  
          # Clusterize boxes
          for j in range(0, len(boxes)):
              index, best_iou = find_matching_box_fast(
                  weighted_boxes, boxes[j], iou_thr
              )
  
              if index != -1:
                  new_boxes[index].append(boxes[j])
                  weighted_boxes[index] = get_weighted_box(
                      new_boxes[index], conf_type
                  )
              else:
                  new_boxes.append([boxes[j].copy()])
                  weighted_boxes = np.vstack(
                      (weighted_boxes, boxes[j].copy())
                  )
  
          # Rescale confidence based on number of models and boxes
          for i in range(len(new_boxes)):
              clustered_boxes = new_boxes[i]
              if conf_type == "box_and_model_avg":
                  clustered_boxes = np.array(clustered_boxes)
                  # weighted average for boxes
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1]
                      * len(clustered_boxes)
                      / weighted_boxes[i, 2]
                  )
                  # identify unique model index by model index column
                  _, idx = np.unique(
                      clustered_boxes[:, 3], return_index=True
                  )
                  # rescale by unique model weights
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1]
                      * clustered_boxes[idx, 2].sum()
                      / weights.sum()
                  )
              elif conf_type == "absent_model_aware_avg":
                  clustered_boxes = np.array(clustered_boxes)
                  # get unique model index in the cluster
                  models = np.unique(clustered_boxes[:, 3]).astype(int)
                  # create a mask to get unused model weights
                  mask = np.ones(len(weights), dtype=bool)
                  mask[models] = False
                  # absent model aware weighted average
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1]
                      * len(clustered_boxes)
                      / (weighted_boxes[i, 2] + weights[mask].sum())
                  )
              elif conf_type == "max":
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1] / weights.max()
                  )
              elif not allows_overflow:
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1]
                      * min(len(weights), len(clustered_boxes))
                      / weights.sum()
                  )
              else:
                  weighted_boxes[i, 1] = (
                      weighted_boxes[i, 1]
                      * len(clustered_boxes)
                      / weights.sum()
                  )
          overall_boxes.append(weighted_boxes)
      overall_boxes = np.concatenate(overall_boxes, axis=0)
      overall_boxes = overall_boxes[overall_boxes[:, 1].argsort()[::-1]]
  
      bboxes = torch.Tensor(overall_boxes[:, 4:])
      scores = torch.Tensor(overall_boxes[:, 1])
      labels = torch.Tensor(overall_boxes[:, 0]).int()
  
      return bboxes, scores, labels
  
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 1 for calling a global function with example usage: weighted_boxes_fusion(bboxes_list, scores_list, labels_list, weights, iou_thr, skip_box_thr, conf_type, allows_overflow) and returns: bboxes,  scores,  labels, torch,  torch,  torch