class_docstr: RepPoint head.
  
  Args:
      point_feat_channels (int): Number of channels of points features.
      gradient_mul (float): The multiplier to gradients from
          points refinement and recognition.
      point_strides (Iterable): points strides.
      point_base_scale (int): bbox scale for assigning labels.
      loss_cls (dict): Config of classification loss.
      loss_bbox_init (dict): Config of initial points loss.
      loss_bbox_refine (dict): Config of points loss in refinement.
      use_grid_points (bool): If we use bounding box representation, the
      reppoints is represented as grid points on the bounding box.
      center_init (bool): Whether to use center point assignment.
      transform_method (str): The methods to transform RepPoints to bbox.
class_docstr_tok: ["RepPoint","head",".","Args",":","point_feat_channels","(","int",")",":","Number","of","channels","of","points","features",".","gradient_mul","(","float",")",":","The","multiplier","to","gradients","from","points","refinement","and","recognition",".","point_strides","(","Iterable",")",":","points","strides",".","point_base_scale","(","int",")",":","bbox","scale","for","assigning","labels",".","loss_cls","(","dict",")",":","Config","of","classification","loss",".","loss_bbox_init","(","dict",")",":","Config","of","initial","points","loss",".","loss_bbox_refine","(","dict",")",":","Config","of","points","loss","in","refinement",".","use_grid_points","(","bool",")",":","If","we","use","bounding","box","representation",",","the","reppoints","is","represented","as","grid","points","on","the","bounding","box",".","center_init","(","bool",")",":","Whether","to","use","center","point","assignment",".","transform_method","(","str",")",":","The","methods","to","transform","RepPoints","to","bbox","."]
docstr: Base on the previous bboxes and regression values, we compute the
  regressed bboxes and generate the grids on the bboxes.
  
  :param reg: the regression value to previous bboxes.
  :param previous_boxes: previous bboxes.
  :return: generate grids on the regressed bboxes.
docstr_tok: ["Base","on","the","previous","bboxes","and","regression","values",",","we","compute","the","regressed","bboxes","and","generate","the","grids","on","the","bboxes",".",":","param","reg",":","the","regression","value","to","previous","bboxes",".",":","param","previous_boxes",":","previous","bboxes",".",":","return",":","generate","grids","on","the","regressed","bboxes","."]
code: def gen_grid_from_reg(self, reg, previous_boxes):
      """Base on the previous bboxes and regression values, we compute the
      regressed bboxes and generate the grids on the bboxes.
  
      :param reg: the regression value to previous bboxes.
      :param previous_boxes: previous bboxes.
      :return: generate grids on the regressed bboxes.
      """
      b, _, h, w = reg.shape
      bxy = (
          previous_boxes[:, :2, ...] + previous_boxes[:, 2:, ...]
      ) / 2.0
      bwh = (
          previous_boxes[:, 2:, ...] - previous_boxes[:, :2, ...]
      ).clamp(min=1e-6)
      grid_topleft = (
          bxy
          + bwh * reg[:, :2, ...]
          - 0.5 * bwh * torch.exp(reg[:, 2:, ...])
      )
      grid_wh = bwh * torch.exp(reg[:, 2:, ...])
      grid_left = grid_topleft[:, [0], ...]
      grid_top = grid_topleft[:, [1], ...]
      grid_width = grid_wh[:, [0], ...]
      grid_height = grid_wh[:, [1], ...]
      intervel = (
          torch.linspace(0.0, 1.0, self.dcn_kernel)
          .view(1, self.dcn_kernel, 1, 1)
          .type_as(reg)
      )
      grid_x = grid_left + grid_width * intervel
      grid_x = grid_x.unsqueeze(1).repeat(1, self.dcn_kernel, 1, 1, 1)
      grid_x = grid_x.view(b, -1, h, w)
      grid_y = grid_top + grid_height * intervel
      grid_y = grid_y.unsqueeze(2).repeat(1, 1, self.dcn_kernel, 1, 1)
      grid_y = grid_y.view(b, -1, h, w)
      grid_yx = torch.stack([grid_y, grid_x], dim=2)
      grid_yx = grid_yx.view(b, -1, h, w)
      regressed_bbox = torch.cat(
          [
              grid_left,
              grid_top,
              grid_left + grid_width,
              grid_top + grid_height,
          ],
          1,
      )
      return grid_yx, regressed_bbox
  
imports: import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, bias_init_with_prob, normal_init
  from mmcv.ops import DeformConv2d
  from mmdet.core import PointGenerator, build_assigner, build_sampler, images_to_levels, multi_apply, multiclass_nms, unmap
  from ..builder import HEADS, build_loss
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 5 for calling the RepPointsHead obj's underlying member method code with example usage: obj.gen_grid_from_reg(reg, previous_boxes) and returns: grid_yx,  regressed_bbox