code: def calc_region(
      bbox: Tensor, ratio: float, featmap_size: Optional[Tuple] = None
  ) -> Tuple[int]:
      """Calculate a proportional bbox region.
  
      The bbox center are fixed and the new h' and w' is h * ratio and w * ratio.
  
      Args:
          bbox (Tensor): Bboxes to calculate regions, shape (n, 4).
          ratio (float): Ratio of the output region.
          featmap_size (tuple, Optional): Feature map size in (height, width)
              order used for clipping the boundary. Defaults to None.
  
      Returns:
          tuple: x1, y1, x2, y2
      """
      x1 = torch.round((1 - ratio) * bbox[0] + ratio * bbox[2]).long()
      y1 = torch.round((1 - ratio) * bbox[1] + ratio * bbox[3]).long()
      x2 = torch.round(ratio * bbox[0] + (1 - ratio) * bbox[2]).long()
      y2 = torch.round(ratio * bbox[1] + (1 - ratio) * bbox[3]).long()
      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)
  
imports: from typing import Optional, Tuple
  import torch
  from torch import Tensor
  from mmdet.structures.bbox import BaseBoxes
label_desc: Use image node_id 2 for calling a global function with example usage: calc_region(bbox, ratio, featmap_size) and returns: x1,  y1,  x2,  y2