code: def _perm_box(
      bboxes,
      iou_calculator,
      iou_thr=0.97,
      perm_range=0.01,
      counter=0,
      max_iter=5,
  ):
      """Compute the permuted bboxes.
  
      Args:
          bboxes (Tensor): Shape (n, 4) for , "xyxy" format.
          iou_calculator (obj): Overlaps Calculator.
          iou_thr (float): The permuted bboxes should have IoU > iou_thr.
          perm_range (float): The scale of permutation.
          counter (int): Counter of permutation iteration.
          max_iter (int): The max iterations of permutation.
      Returns:
          Tensor: The permuted bboxes.
      """
      ori_bboxes = copy.deepcopy(bboxes)
      is_valid = True
      N = bboxes.size(0)
      perm_factor = bboxes.new_empty(N, 4).uniform_(
          1 - perm_range, 1 + perm_range
      )
      bboxes *= perm_factor
      new_wh = bboxes[:, 2:] - bboxes[:, :2]
      if (new_wh <= 0).any():
          is_valid = False
      iou = iou_calculator(ori_bboxes.unique(dim=0), bboxes)
      if (iou < iou_thr).any():
          is_valid = False
      if not is_valid and counter < max_iter:
          return _perm_box(
              ori_bboxes,
              iou_calculator,
              perm_range=max(perm_range - counter * 0.001, 1e-3),
              counter=counter + 1,
          )
      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 1 for calling a global function with example usage: _perm_box(bboxes, iou_calculator, iou_thr, perm_range, counter, max_iter) and returns: bboxes, _perm_box