class_docstr: RepPoint head.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      point_feat_channels (int): Number of channels of points features.
      num_points (int): Number of points.
      gradient_mul (float): The multiplier to gradients from
          points refinement and recognition.
      point_strides (Sequence[int]): points strides.
      point_base_scale (int): bbox scale for assigning labels.
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox_init (:obj:`ConfigDict` or dict): Config of initial points
          loss.
      loss_bbox_refine (:obj:`ConfigDict` or 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.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict]): Initialization config dict.
class_docstr_tok: ["RepPoint","head",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","point_feat_channels","(","int",")",":","Number","of","channels","of","points","features",".","num_points","(","int",")",":","Number","of","points",".","gradient_mul","(","float",")",":","The","multiplier","to","gradients","from","points","refinement","and","recognition",".","point_strides","(","Sequence","[","int","]",")",":","points","strides",".","point_base_scale","(","int",")",":","bbox","scale","for","assigning","labels",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox_init","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","initial","points","loss",".","loss_bbox_refine","(",":","obj",":","`","ConfigDict","`","or","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",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",")",":","Initialization","config","dict","."]
code: def __init__(
      self,
      num_classes: int,
      in_channels: int,
      point_feat_channels: int = 256,
      num_points: int = 9,
      gradient_mul: float = 0.1,
      point_strides: Sequence[int] = [8, 16, 32, 64, 128],
      point_base_scale: int = 4,
      loss_cls: ConfigType = dict(
          type="FocalLoss",
          use_sigmoid=True,
          gamma=2.0,
          alpha=0.25,
          loss_weight=1.0,
      ),
      loss_bbox_init: ConfigType = dict(
          type="SmoothL1Loss", beta=1.0 / 9.0, loss_weight=0.5
      ),
      loss_bbox_refine: ConfigType = dict(
          type="SmoothL1Loss", beta=1.0 / 9.0, loss_weight=1.0
      ),
      use_grid_points: bool = False,
      center_init: bool = True,
      transform_method: str = "moment",
      moment_mul: float = 0.01,
      init_cfg: MultiConfig = dict(
          type="Normal",
          layer="Conv2d",
          std=0.01,
          override=dict(
              type="Normal",
              name="reppoints_cls_out",
              std=0.01,
              bias_prob=0.01,
          ),
      ),
      **kwargs,
  ) -> None:
      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=num_classes,
          in_channels=in_channels,
          loss_cls=loss_cls,
          init_cfg=init_cfg,
          **kwargs,
      )
  
      self.gradient_mul = gradient_mul
      self.point_base_scale = point_base_scale
      self.point_strides = point_strides
      self.prior_generator = MlvlPointGenerator(
          self.point_strides, offset=0.0
      )
  
      if self.train_cfg:
          self.init_assigner = TASK_UTILS.build(
              self.train_cfg["init"]["assigner"]
          )
          self.refine_assigner = TASK_UTILS.build(
              self.train_cfg["refine"]["assigner"]
          )
  
          if self.train_cfg.get("sampler", None) is not None:
              self.sampler = TASK_UTILS.build(
                  self.train_cfg["sampler"],
                  default_args=dict(context=self),
              )
          else:
              self.sampler = PseudoSampler(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 = MODELS.build(loss_bbox_init)
      self.loss_bbox_refine = MODELS.build(loss_bbox_refine)
  
imports: from typing import Dict, List, Sequence, Tuple
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmcv.ops import DeformConv2d
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptInstanceList
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..task_modules.samplers import PseudoSampler
  from ..utils import filter_scores_and_topk, images_to_levels, multi_apply, unmap
  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, init_cfg)