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 loss(
      self,
      cls_scores,
      pts_preds_init,
      pts_preds_refine,
      gt_bboxes,
      gt_labels,
      img_metas,
      gt_bboxes_ignore=None,
  ):
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
      assert len(featmap_sizes) == len(self.point_generators)
      device = cls_scores[0].device
      label_channels = (
          self.cls_out_channels if self.use_sigmoid_cls else 1
      )
  
      # target for initial stage
      center_list, valid_flag_list = self.get_points(
          featmap_sizes, img_metas, device
      )
      pts_coordinate_preds_init = self.offset_to_pts(
          center_list, pts_preds_init
      )
      if self.train_cfg.init.assigner["type"] == "PointAssigner":
          # Assign target for center list
          candidate_list = center_list
      else:
          # transform center list to bbox list and
          #   assign target for bbox list
          bbox_list = self.centers_to_bboxes(center_list)
          candidate_list = bbox_list
      cls_reg_targets_init = self.get_targets(
          candidate_list,
          valid_flag_list,
          gt_bboxes,
          img_metas,
          gt_bboxes_ignore_list=gt_bboxes_ignore,
          gt_labels_list=gt_labels,
          stage="init",
          label_channels=label_channels,
      )
      (
          *_,
          bbox_gt_list_init,
          candidate_list_init,
          bbox_weights_list_init,
          num_total_pos_init,
          num_total_neg_init,
      ) = cls_reg_targets_init
      num_total_samples_init = (
          num_total_pos_init + num_total_neg_init
          if self.sampling
          else num_total_pos_init
      )
  
      # target for refinement stage
      center_list, valid_flag_list = self.get_points(
          featmap_sizes, img_metas, device
      )
      pts_coordinate_preds_refine = self.offset_to_pts(
          center_list, pts_preds_refine
      )
      bbox_list = []
      for i_img, center in enumerate(center_list):
          bbox = []
          for i_lvl in range(len(pts_preds_refine)):
              bbox_preds_init = self.points2bbox(
                  pts_preds_init[i_lvl].detach()
              )
              bbox_shift = bbox_preds_init * self.point_strides[i_lvl]
              bbox_center = torch.cat(
                  [center[i_lvl][:, :2], center[i_lvl][:, :2]], dim=1
              )
              bbox.append(
                  bbox_center
                  + bbox_shift[i_img].permute(1, 2, 0).reshape(-1, 4)
              )
          bbox_list.append(bbox)
      cls_reg_targets_refine = self.get_targets(
          bbox_list,
          valid_flag_list,
          gt_bboxes,
          img_metas,
          gt_bboxes_ignore_list=gt_bboxes_ignore,
          gt_labels_list=gt_labels,
          stage="refine",
          label_channels=label_channels,
      )
      (
          labels_list,
          label_weights_list,
          bbox_gt_list_refine,
          candidate_list_refine,
          bbox_weights_list_refine,
          num_total_pos_refine,
          num_total_neg_refine,
      ) = cls_reg_targets_refine
      num_total_samples_refine = (
          num_total_pos_refine + num_total_neg_refine
          if self.sampling
          else num_total_pos_refine
      )
  
      # compute loss
      losses_cls, losses_pts_init, losses_pts_refine = multi_apply(
          self.loss_single,
          cls_scores,
          pts_coordinate_preds_init,
          pts_coordinate_preds_refine,
          labels_list,
          label_weights_list,
          bbox_gt_list_init,
          bbox_weights_list_init,
          bbox_gt_list_refine,
          bbox_weights_list_refine,
          self.point_strides,
          num_total_samples_init=num_total_samples_init,
          num_total_samples_refine=num_total_samples_refine,
      )
      loss_dict_all = {
          "loss_cls": losses_cls,
          "loss_pts_init": losses_pts_init,
          "loss_pts_refine": losses_pts_refine,
      }
      return loss_dict_all
  
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 14 for calling the RepPointsHead obj's underlying member method code with example usage: obj.loss(cls_scores, pts_preds_init, pts_preds_refine, gt_bboxes, gt_labels, img_metas, gt_bboxes_ignore) and returns: loss_dict_all