class_docstr: Implementation of `Grid Head <https://arxiv.org/abs/1811.12030>`_
  
  Args:
      grid_points (int): The number of grid points. Defaults to 9.
      num_convs (int): The number of convolution layers. Defaults to 8.
      roi_feat_size (int): RoI feature size. Default to 14.
      in_channels (int): The channel number of inputs features.
          Defaults to 256.
      conv_kernel_size (int): The kernel size of convolution layers.
          Defaults to 3.
      point_feat_channels (int): The number of channels of each point
          features. Defaults to 64.
      class_agnostic (bool): Whether use class agnostic classification.
          If so, the output channels of logits will be 1. Defaults to False.
      loss_grid (:obj:`ConfigDict` or dict): Config of grid loss.
      conv_cfg (:obj:`ConfigDict` or dict, optional) dictionary to
          construct and config conv layer.
      norm_cfg (:obj:`ConfigDict` or dict): dictionary to construct and
          config norm layer.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict]): Initialization config dict.
docstr: Adjust ``bboxes`` according to ``grid_pred``.
  
  Args:
      grid_pred (Tensor): Grid fused heatmap.
      bboxes (Tensor): Predicted bboxes, has shape (n, 4)
      img_meta (dict): image information.
      rescale (bool): If True, return boxes in original image space.
          Defaults to False.
  
  Returns:
      Tensor: adjusted bboxes.
docstr_tok: ["Adjust","``","bboxes","``","according","to","``","grid_pred","``",".","Args",":","grid_pred","(","Tensor",")",":","Grid","fused","heatmap",".","bboxes","(","Tensor",")",":","Predicted","bboxes",",","has","shape","(","n",",","4",")","img_meta","(","dict",")",":","image","information",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Defaults","to","False",".","Returns",":","Tensor",":","adjusted","bboxes","."]
code: def _predict_by_feat_single(
      self,
      grid_pred: Tensor,
      bboxes: Tensor,
      img_meta: dict,
      rescale: bool = False,
  ) -> Tensor:
      """Adjust ``bboxes`` according to ``grid_pred``.
  
      Args:
          grid_pred (Tensor): Grid fused heatmap.
          bboxes (Tensor): Predicted bboxes, has shape (n, 4)
          img_meta (dict): image information.
          rescale (bool): If True, return boxes in original image space.
              Defaults to False.
  
      Returns:
          Tensor: adjusted bboxes.
      """
      assert bboxes.size(0) == grid_pred.size(0)
      grid_pred = grid_pred.sigmoid()
  
      R, c, h, w = grid_pred.shape
      half_size = self.whole_map_size // 4 * 2
      assert h == w == half_size
      assert c == self.grid_points
  
      # find the point with max scores in the half-sized heatmap
      grid_pred = grid_pred.view(R * c, h * w)
      pred_scores, pred_position = grid_pred.max(dim=1)
      xs = pred_position % w
      ys = pred_position // w
  
      # get the position in the whole heatmap instead of half-sized heatmap
      for i in range(self.grid_points):
          xs[i :: self.grid_points] += self.sub_regions[i][0]
          ys[i :: self.grid_points] += self.sub_regions[i][1]
  
      # reshape to (num_rois, grid_points)
      pred_scores, xs, ys = tuple(
          map(lambda x: x.view(R, c), [pred_scores, xs, ys])
      )
  
      # get expanded pos_bboxes
      widths = (bboxes[:, 2] - bboxes[:, 0]).unsqueeze(-1)
      heights = (bboxes[:, 3] - bboxes[:, 1]).unsqueeze(-1)
      x1 = bboxes[:, 0, None] - widths / 2
      y1 = bboxes[:, 1, None] - heights / 2
      # map the grid point to the absolute coordinates
      abs_xs = (xs.float() + 0.5) / w * widths + x1
      abs_ys = (ys.float() + 0.5) / h * heights + y1
  
      # get the grid points indices that fall on the bbox boundaries
      x1_inds = [i for i in range(self.grid_size)]
      y1_inds = [i * self.grid_size for i in range(self.grid_size)]
      x2_inds = [
          self.grid_points - self.grid_size + i
          for i in range(self.grid_size)
      ]
      y2_inds = [
          (i + 1) * self.grid_size - 1 for i in range(self.grid_size)
      ]
  
      # voting of all grid points on some boundary
      bboxes_x1 = (abs_xs[:, x1_inds] * pred_scores[:, x1_inds]).sum(
          dim=1, keepdim=True
      ) / (pred_scores[:, x1_inds].sum(dim=1, keepdim=True))
      bboxes_y1 = (abs_ys[:, y1_inds] * pred_scores[:, y1_inds]).sum(
          dim=1, keepdim=True
      ) / (pred_scores[:, y1_inds].sum(dim=1, keepdim=True))
      bboxes_x2 = (abs_xs[:, x2_inds] * pred_scores[:, x2_inds]).sum(
          dim=1, keepdim=True
      ) / (pred_scores[:, x2_inds].sum(dim=1, keepdim=True))
      bboxes_y2 = (abs_ys[:, y2_inds] * pred_scores[:, y2_inds]).sum(
          dim=1, keepdim=True
      ) / (pred_scores[:, y2_inds].sum(dim=1, keepdim=True))
  
      bboxes = torch.cat(
          [bboxes_x1, bboxes_y1, bboxes_x2, bboxes_y2], dim=1
      )
      bboxes[:, [0, 2]].clamp_(min=0, max=img_meta["img_shape"][1])
      bboxes[:, [1, 3]].clamp_(min=0, max=img_meta["img_shape"][0])
  
      if rescale:
          assert img_meta.get("scale_factor") is not None
          bboxes /= bboxes.new_tensor(img_meta["scale_factor"]).repeat(
              (1, 2)
          )
  
      return bboxes
  
imports: from typing import Dict, List, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.task_modules.samplers import SamplingResult
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType
label_desc: Use image node_id 7 for calling the GridHead obj's underlying member method code with example usage: obj._predict_by_feat_single(grid_pred, bboxes, img_meta, rescale) and returns: bboxes