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","."]
code: def __init__(
      self,
      num_classes,
      in_channels,
      point_feat_channels=256,
      num_points=9,
      gradient_mul=0.1,
      point_strides=[8, 16, 32, 64, 128],
      point_base_scale=4,
      loss_cls=dict(
          type="FocalLoss",
          use_sigmoid=True,
          gamma=2.0,
          alpha=0.25,
          loss_weight=1.0,
      ),
      loss_bbox_init=dict(
          type="SmoothL1Loss", beta=1.0 / 9.0, loss_weight=0.5
      ),
      loss_bbox_refine=dict(
          type="SmoothL1Loss", beta=1.0 / 9.0, loss_weight=1.0
      ),
      use_grid_points=False,
      center_init=True,
      transform_method="moment",
      moment_mul=0.01,
      **kwargs,
  ):
      self.num_points = num_points
      self.point_feat_channels = point_feat_channels
      self.use_grid_points = use_grid_points
      self.center_init = center_init
  
      # we use deform conv to extract points features
      self.dcn_kernel = int(np.sqrt(num_points))
      self.dcn_pad = int((self.dcn_kernel - 1) / 2)
      assert (
          self.dcn_kernel * self.dcn_kernel == num_points
      ), "The points number should be a square number."
      assert (
          self.dcn_kernel % 2 == 1
      ), "The points number should be an odd square number."
      dcn_base = np.arange(-self.dcn_pad, self.dcn_pad + 1).astype(
          np.float64
      )
      dcn_base_y = np.repeat(dcn_base, self.dcn_kernel)
      dcn_base_x = np.tile(dcn_base, self.dcn_kernel)
      dcn_base_offset = np.stack(
          [dcn_base_y, dcn_base_x], axis=1
      ).reshape((-1))
      self.dcn_base_offset = torch.tensor(dcn_base_offset).view(
          1, -1, 1, 1
      )
  
      super().__init__(
          num_classes, in_channels, loss_cls=loss_cls, **kwargs
      )
  
      self.gradient_mul = gradient_mul
      self.point_base_scale = point_base_scale
      self.point_strides = point_strides
      self.point_generators = [
          PointGenerator() for _ in self.point_strides
      ]
  
      self.sampling = loss_cls["type"] not in ["FocalLoss"]
      if self.train_cfg:
          self.init_assigner = build_assigner(
              self.train_cfg.init.assigner
          )
          self.refine_assigner = build_assigner(
              self.train_cfg.refine.assigner
          )
          # use PseudoSampler when sampling is False
          if self.sampling and hasattr(self.train_cfg, "sampler"):
              sampler_cfg = self.train_cfg.sampler
          else:
              sampler_cfg = dict(type="PseudoSampler")
          self.sampler = build_sampler(sampler_cfg, context=self)
      self.transform_method = transform_method
      if self.transform_method == "moment":
          self.moment_transfer = nn.Parameter(
              data=torch.zeros(2), requires_grad=True
          )
          self.moment_mul = moment_mul
  
      self.use_sigmoid_cls = loss_cls.get("use_sigmoid", False)
      if self.use_sigmoid_cls:
          self.cls_out_channels = self.num_classes
      else:
          self.cls_out_channels = self.num_classes + 1
      self.loss_bbox_init = build_loss(loss_bbox_init)
      self.loss_bbox_refine = build_loss(loss_bbox_refine)
  
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 1 to create a new RepPointsHead object from inherited base classes: AnchorFreeHead with example: obj = RepPointsHead(num_classes, in_channels, point_feat_channels, num_points, gradient_mul, point_strides, point_base_scale, loss_cls, loss_bbox_init, loss_bbox_refine, use_grid_points, center_init, transform_method, moment_mul)