docstr: Compute point specific representation regions.
  
  See Grid R-CNN Plus (https://arxiv.org/abs/1906.05688) for details.
docstr_tok: ["Compute","point","specific","representation","regions",".","See","Grid","R-CNN","Plus","(","https",":","\/\/arxiv.org\/abs\/1906.05688",")","for","details","."]
code: def calc_sub_regions(self):
      """Compute point specific representation regions.
  
      See Grid R-CNN Plus (https://arxiv.org/abs/1906.05688) for details.
      """
      # to make it consistent with the original implementation, half_size
      # is computed as 2 * quarter_size, which is smaller
      half_size = self.whole_map_size // 4 * 2
      sub_regions = []
      for i in range(self.grid_points):
          x_idx = i // self.grid_size
          y_idx = i % self.grid_size
          if x_idx == 0:
              sub_x1 = 0
          elif x_idx == self.grid_size - 1:
              sub_x1 = half_size
          else:
              ratio = x_idx / (self.grid_size - 1) - 0.25
              sub_x1 = max(int(ratio * self.whole_map_size), 0)
  
          if y_idx == 0:
              sub_y1 = 0
          elif y_idx == self.grid_size - 1:
              sub_y1 = half_size
          else:
              ratio = y_idx / (self.grid_size - 1) - 0.25
              sub_y1 = max(int(ratio * self.whole_map_size), 0)
          sub_regions.append(
              (sub_x1, sub_y1, sub_x1 + half_size, sub_y1 + half_size)
          )
      return sub_regions
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/mask_heads/grid_head.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, kaiming_init, normal_init
  from mmdet.models.builder import HEADS, build_loss
label_desc: Use image node_id 4 for calling the GridHead obj's underlying member method code with example usage: obj.calc_sub_regions() and returns: sub_regions