code: def calc_region(
      bbox: Tensor,
      ratio: float,
      stride: int,
      featmap_size: Optional[Tuple[int, int]] = None,
  ) -> Tuple[Tensor]:
      """Calculate region of the box defined by the ratio, the ratio is from the
      center of the box to every edge."""
      # project bbox on the feature
      f_bbox = bbox / stride
      x1 = torch.round((1 - ratio) * f_bbox[0] + ratio * f_bbox[2])
      y1 = torch.round((1 - ratio) * f_bbox[1] + ratio * f_bbox[3])
      x2 = torch.round(ratio * f_bbox[0] + (1 - ratio) * f_bbox[2])
      y2 = torch.round(ratio * f_bbox[1] + (1 - ratio) * f_bbox[3])
      if featmap_size is not None:
          x1 = x1.clamp(min=0, max=featmap_size[1])
          y1 = y1.clamp(min=0, max=featmap_size[0])
          x2 = x2.clamp(min=0, max=featmap_size[1])
          y2 = y2.clamp(min=0, max=featmap_size[0])
      return (x1, y1, x2, y2)
  
file_path: mmdetection/mmdet/models/task_modules/assigners/region_assigner.py
imports: from typing import List, Optional, Tuple
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from ..prior_generators import anchor_inside_flags
  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: calc_region(bbox, ratio, stride, featmap_size) and returns: x1,  y1,  x2,  y2