code: def generat_buckets(proposals, num_buckets, scale_factor=1.0):
      """Generate buckets w.r.t bucket number and scale factor of proposals.
  
      Args:
          proposals (Tensor): Shape (n, 4)
          num_buckets (int): Number of buckets.
          scale_factor (float): Scale factor to rescale proposals.
  
      Returns:
          tuple[Tensor]: (bucket_w, bucket_h, l_buckets, r_buckets,
           t_buckets, d_buckets)
  
              - bucket_w: Width of buckets on x-axis. Shape (n, ).
              - bucket_h: Height of buckets on y-axis. Shape (n, ).
              - l_buckets: Left buckets. Shape (n, ceil(side_num/2)).
              - r_buckets: Right buckets. Shape (n, ceil(side_num/2)).
              - t_buckets: Top buckets. Shape (n, ceil(side_num/2)).
              - d_buckets: Down buckets. Shape (n, ceil(side_num/2)).
      """
      proposals = bbox_rescale(proposals, scale_factor)
  
      # number of buckets in each side
      side_num = int(np.ceil(num_buckets / 2.0))
      pw = proposals[..., 2] - proposals[..., 0]
      ph = proposals[..., 3] - proposals[..., 1]
      px1 = proposals[..., 0]
      py1 = proposals[..., 1]
      px2 = proposals[..., 2]
      py2 = proposals[..., 3]
  
      bucket_w = pw / num_buckets
      bucket_h = ph / num_buckets
  
      # left buckets
      l_buckets = (
          px1[:, None]
          + (0.5 + torch.arange(0, side_num).to(proposals).float())[
              None, :
          ]
          * bucket_w[:, None]
      )
      # right buckets
      r_buckets = (
          px2[:, None]
          - (0.5 + torch.arange(0, side_num).to(proposals).float())[
              None, :
          ]
          * bucket_w[:, None]
      )
      # top buckets
      t_buckets = (
          py1[:, None]
          + (0.5 + torch.arange(0, side_num).to(proposals).float())[
              None, :
          ]
          * bucket_h[:, None]
      )
      # down buckets
      d_buckets = (
          py2[:, None]
          - (0.5 + torch.arange(0, side_num).to(proposals).float())[
              None, :
          ]
          * bucket_h[:, None]
      )
      return (
          bucket_w,
          bucket_h,
          l_buckets,
          r_buckets,
          t_buckets,
          d_buckets,
      )
  
file_path: insightface/detection/scrfd/mmdet/core/bbox/coder/bucketing_bbox_coder.py
imports: import numpy
  import torch
  import torch.nn.functional
  from ..builder import BBOX_CODERS
  from ..transforms import bbox_rescale
  from .base_bbox_coder import BaseBBoxCoder
label_desc: Use image node_id 1 for calling a global function with example usage: generat_buckets(proposals, num_buckets, scale_factor) and returns: bucket_w,  bucket_h,  l_buckets,  r_buckets,  t_buckets,  d_buckets