class_docstr: Objects as Points Head. CenterHead use center_point to indicate object's
  position. Paper link <https://arxiv.org/abs/1904.07850>
  
  Args:
      in_channels (int): Number of channel in the input feature map.
      feat_channels (int): Number of channel in the intermediate feature map.
      num_classes (int): Number of categories excluding the background
          category.
      loss_center_heatmap (:obj:`ConfigDict` or dict): Config of center
          heatmap loss. Defaults to
          dict(type='GaussianFocalLoss', loss_weight=1.0)
      loss_wh (:obj:`ConfigDict` or dict): Config of wh loss. Defaults to
           dict(type='L1Loss', loss_weight=0.1).
      loss_offset (:obj:`ConfigDict` or dict): Config of offset loss.
          Defaults to dict(type='L1Loss', loss_weight=1.0).
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config.
          Useless in CenterNet, but we keep this variable for
          SingleStageDetector.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config
          of CenterNet.
      init_cfg (:obj:`ConfigDict` or dict or list[dict] or
          list[:obj:`ConfigDict`], optional): Initialization
          config dict.
docstr: Compute losses of the head.
  
  Args:
      center_heatmap_preds (list[Tensor]): center predict heatmaps for
         all levels with shape (B, num_classes, H, W).
      wh_preds (list[Tensor]): wh predicts for all levels with
         shape (B, 2, H, W).
      offset_preds (list[Tensor]): offset predicts for all levels
         with shape (B, 2, H, W).
      batch_gt_instances (list[:obj:`InstanceData`]): Batch of
          gt_instance. It usually includes ``bboxes`` and ``labels``
          attributes.
      batch_img_metas (list[dict]): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      batch_gt_instances_ignore (list[:obj:`InstanceData`], optional):
          Batch of gt_instances_ignore. It includes ``bboxes`` attribute
          data that is ignored during training and testing.
          Defaults to None.
  
  Returns:
      dict[str, Tensor]: which has components below:
          - loss_center_heatmap (Tensor): loss of center heatmap.
          - loss_wh (Tensor): loss of hw heatmap
          - loss_offset (Tensor): loss of offset heatmap.
docstr_tok: ["Compute","losses","of","the","head",".","Args",":","center_heatmap_preds","(","list","[","Tensor","]",")",":","center","predict","heatmaps","for","all","levels","with","shape","(","B",",","num_classes",",","H",",","W",")",".","wh_preds","(","list","[","Tensor","]",")",":","wh","predicts","for","all","levels","with","shape","(","B",",","2",",","H",",","W",")",".","offset_preds","(","list","[","Tensor","]",")",":","offset","predicts","for","all","levels","with","shape","(","B",",","2",",","H",",","W",")",".","batch_gt_instances","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Batch","of","gt_instance",".","It","usually","includes","``","bboxes","``","and","``","labels","``","attributes",".","batch_img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","batch_gt_instances_ignore","(","list","[",":","obj",":","`","InstanceData","`","]",",","optional",")",":","Batch","of","gt_instances_ignore",".","It","includes","``","bboxes","``","attribute","data","that","is","ignored","during","training","and","testing",".","Defaults","to","None",".","Returns",":","dict","[","str",",","Tensor","]",":","which","has","components","below",":","-","loss_center_heatmap","(","Tensor",")",":","loss","of","center","heatmap",".","-","loss_wh","(","Tensor",")",":","loss","of","hw","heatmap","-","loss_offset","(","Tensor",")",":","loss","of","offset","heatmap","."]
code: def loss_by_feat(
      self,
      center_heatmap_preds: List[Tensor],
      wh_preds: List[Tensor],
      offset_preds: List[Tensor],
      batch_gt_instances: InstanceList,
      batch_img_metas: List[dict],
      batch_gt_instances_ignore: OptInstanceList = None,
  ) -> dict:
      """Compute losses of the head.
  
      Args:
          center_heatmap_preds (list[Tensor]): center predict heatmaps for
             all levels with shape (B, num_classes, H, W).
          wh_preds (list[Tensor]): wh predicts for all levels with
             shape (B, 2, H, W).
          offset_preds (list[Tensor]): offset predicts for all levels
             with shape (B, 2, H, W).
          batch_gt_instances (list[:obj:`InstanceData`]): Batch of
              gt_instance. It usually includes ``bboxes`` and ``labels``
              attributes.
          batch_img_metas (list[dict]): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          batch_gt_instances_ignore (list[:obj:`InstanceData`], optional):
              Batch of gt_instances_ignore. It includes ``bboxes`` attribute
              data that is ignored during training and testing.
              Defaults to None.
  
      Returns:
          dict[str, Tensor]: which has components below:
              - loss_center_heatmap (Tensor): loss of center heatmap.
              - loss_wh (Tensor): loss of hw heatmap
              - loss_offset (Tensor): loss of offset heatmap.
      """
      assert (
          len(center_heatmap_preds)
          == len(wh_preds)
          == len(offset_preds)
          == 1
      )
      center_heatmap_pred = center_heatmap_preds[0]
      wh_pred = wh_preds[0]
      offset_pred = offset_preds[0]
  
      gt_bboxes = [
          gt_instances.bboxes for gt_instances in batch_gt_instances
      ]
      gt_labels = [
          gt_instances.labels for gt_instances in batch_gt_instances
      ]
      img_shape = batch_img_metas[0]["batch_input_shape"]
      target_result, avg_factor = self.get_targets(
          gt_bboxes, gt_labels, center_heatmap_pred.shape, img_shape
      )
  
      center_heatmap_target = target_result["center_heatmap_target"]
      wh_target = target_result["wh_target"]
      offset_target = target_result["offset_target"]
      wh_offset_target_weight = target_result["wh_offset_target_weight"]
  
      # Since the channel of wh_target and offset_target is 2, the avg_factor
      # of loss_center_heatmap is always 1/2 of loss_wh and loss_offset.
      loss_center_heatmap = self.loss_center_heatmap(
          center_heatmap_pred,
          center_heatmap_target,
          avg_factor=avg_factor,
      )
      loss_wh = self.loss_wh(
          wh_pred,
          wh_target,
          wh_offset_target_weight,
          avg_factor=avg_factor * 2,
      )
      loss_offset = self.loss_offset(
          offset_pred,
          offset_target,
          wh_offset_target_weight,
          avg_factor=avg_factor * 2,
      )
      return dict(
          loss_center_heatmap=loss_center_heatmap,
          loss_wh=loss_wh,
          loss_offset=loss_offset,
      )
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.ops import batched_nms
  from mmengine.config import ConfigDict
  from mmengine.model import bias_init_with_prob, normal_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList, OptMultiConfig
  from ..utils import gaussian_radius, gen_gaussian_target, get_local_maximum, get_topk_from_heatmap, multi_apply, transpose_and_gather_feat
  from .base_dense_head import BaseDenseHead
label_desc: Use image node_id 6 for calling the CenterNetHead obj's underlying member method code with example usage: obj.loss_by_feat(center_heatmap_preds, wh_preds, offset_preds, batch_gt_instances, batch_img_metas, batch_gt_instances_ignore) and returns: dict