code: def perm_repeat_bboxes(
      bboxes, iou_calculator=None, perm_repeat_cfg=None
  ):
      """Permute the repeated bboxes.
  
      Args:
          bboxes (Tensor): Shape (n, 4) for , "xyxy" format.
          iou_calculator (obj): Overlaps Calculator.
          perm_repeat_cfg (Dict): Config of permutation.
      Returns:
          Tensor: Bboxes after permuted repeated bboxes.
      """
      assert isinstance(bboxes, torch.Tensor)
      if iou_calculator is None:
          import torchvision
  
          iou_calculator = torchvision.ops.box_iou
      bboxes = copy.deepcopy(bboxes)
      unique_bboxes = bboxes.unique(dim=0)
      iou_thr = perm_repeat_cfg.get("iou_thr", 0.97)
      perm_range = perm_repeat_cfg.get("perm_range", 0.01)
      for box in unique_bboxes:
          inds = (bboxes == box).sum(-1).float() == 4
          if inds.float().sum().item() == 1:
              continue
          bboxes[inds] = _perm_box(
              bboxes[inds],
              iou_calculator,
              iou_thr=iou_thr,
              perm_range=perm_range,
              counter=0,
          )
      return bboxes
  
file_path: mmdetection/mmdet/models/task_modules/assigners/max_iou_assigner.py
imports: import copy
  from typing import Optional, Union
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from .assign_result import AssignResult
  from .base_assigner import BaseAssigner
label_desc: Use image node_id 2 for calling a global function with example usage: perm_repeat_bboxes(bboxes, iou_calculator, perm_repeat_cfg) and returns: bboxes