class_docstr: CenterNetUpdateHead is an improved version of CenterNet in CenterNet2.
  
  Paper link `<https://arxiv.org/abs/2103.07461>`_.
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channel in the input feature map.
      regress_ranges (Sequence[Tuple[int, int]]): Regress range of multiple
          level points.
      hm_min_radius (int): Heatmap target minimum radius of cls branch.
          Defaults to 4.
      hm_min_overlap (float): Heatmap target minimum overlap of cls branch.
          Defaults to 0.8.
      more_pos_thresh (float): The filtering threshold when the cls branch
          adds more positive samples. Defaults to 0.2.
      more_pos_topk (int): The maximum number of additional positive samples
          added to each gt. Defaults to 9.
      soft_weight_on_reg (bool): Whether to use the soft target of the
          cls branch as the soft weight of the bbox branch.
          Defaults to False.
      loss_cls (:obj:`ConfigDict` or dict): Config of cls loss. Defaults to
          dict(type='GaussianFocalLoss', loss_weight=1.0)
      loss_bbox (:obj:`ConfigDict` or dict): Config of bbox loss. Defaults to
           dict(type='GIoULoss', loss_weight=2.0).
      norm_cfg (:obj:`ConfigDict` or dict, optional): dictionary to construct
          and config norm layer.  Defaults to
          ``norm_cfg=dict(type='GN', num_groups=32, requires_grad=True)``.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config.
          Unused in CenterNet. Reserved for compatibility with
          SingleStageDetector.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config
          of CenterNet.
class_docstr_tok: ["CenterNetUpdateHead","is","an","improved","version","of","CenterNet","in","CenterNet2",".","Paper","link","`","<","https",":","\/\/arxiv.org\/abs\/2103.07461",">","`","_",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channel","in","the","input","feature","map",".","regress_ranges","(","Sequence","[","Tuple","[","int",",","int","]","]",")",":","Regress","range","of","multiple","level","points",".","hm_min_radius","(","int",")",":","Heatmap","target","minimum","radius","of","cls","branch",".","Defaults","to","4.","hm_min_overlap","(","float",")",":","Heatmap","target","minimum","overlap","of","cls","branch",".","Defaults","to","0.8.","more_pos_thresh","(","float",")",":","The","filtering","threshold","when","the","cls","branch","adds","more","positive","samples",".","Defaults","to","0.2.","more_pos_topk","(","int",")",":","The","maximum","number","of","additional","positive","samples","added","to","each","gt",".","Defaults","to","9.","soft_weight_on_reg","(","bool",")",":","Whether","to","use","the","soft","target","of","the","cls","branch","as","the","soft","weight","of","the","bbox","branch",".","Defaults","to","False",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","cls","loss",".","Defaults","to","dict","(","type='GaussianFocalLoss","'",",","loss_weight=1.0",")","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","bbox","loss",".","Defaults","to","dict","(","type='GIoULoss","'",",","loss_weight=2.0",")",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","dictionary","to","construct","and","config","norm","layer",".","Defaults","to","``","norm_cfg=dict","(","type='GN","'",",","num_groups=32",",","requires_grad=True",")","``",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config",".","Unused","in","CenterNet",".","Reserved","for","compatibility","with","SingleStageDetector",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","CenterNet","."]
docstr: Perform forward propagation of the head, then calculate loss and
  predictions from the features and data samples.
  
  Args:
      x (tuple[Tensor]): Features from FPN.
      batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
          the meta information of each image and corresponding
          annotations.
      proposal_cfg (ConfigDict, optional): Test / postprocessing
          configuration, if None, test_cfg would be used.
          Defaults to None.
  
  Returns:
      tuple: the return value is a tuple contains:
  
          - losses: (dict[str, Tensor]): A dictionary of loss components.
          - predictions (list[:obj:`InstanceData`]): Detection
            results of each image after the post process.
docstr_tok: ["Perform","forward","propagation","of","the","head",",","then","calculate","loss","and","predictions","from","the","features","and","data","samples",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Features","from","FPN",".","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","Each","item","contains","the","meta","information","of","each","image","and","corresponding","annotations",".","proposal_cfg","(","ConfigDict",",","optional",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","Defaults","to","None",".","Returns",":","tuple",":","the","return","value","is","a","tuple","contains",":","-","losses",":","(","dict","[","str",",","Tensor","]",")",":","A","dictionary","of","loss","components",".","-","predictions","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Detection","results","of","each","image","after","the","post","process","."]
code: def loss_and_predict(
      self,
      x: Tuple[Tensor],
      batch_data_samples: SampleList,
      proposal_cfg: Optional[ConfigDict] = None,
  ) -> Tuple[dict, InstanceList]:
      """Perform forward propagation of the head, then calculate loss and
      predictions from the features and data samples.
  
      Args:
          x (tuple[Tensor]): Features from FPN.
          batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
              the meta information of each image and corresponding
              annotations.
          proposal_cfg (ConfigDict, optional): Test / postprocessing
              configuration, if None, test_cfg would be used.
              Defaults to None.
  
      Returns:
          tuple: the return value is a tuple contains:
  
              - losses: (dict[str, Tensor]): A dictionary of loss components.
              - predictions (list[:obj:`InstanceData`]): Detection
                results of each image after the post process.
      """
      outputs = unpack_gt_instances(batch_data_samples)
      (
          batch_gt_instances,
          batch_gt_instances_ignore,
          batch_img_metas,
      ) = outputs
  
      outs = self(x)
  
      loss_inputs = outs + (
          batch_gt_instances,
          batch_img_metas,
          batch_gt_instances_ignore,
      )
      losses = self.loss_by_feat(*loss_inputs)
      predictions = self.predict_by_feat(
          *outs, batch_img_metas=batch_img_metas, cfg=proposal_cfg
      )
      return losses, predictions
  
imports: import copy
  from typing import Dict, List, Optional, Sequence, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import Scale
  from mmengine import ConfigDict
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.dense_heads import CenterNetUpdateHead
  from mmdet.models.utils import unpack_gt_instances
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2distance
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList, reduce_mean
  from .iou_loss import IOULoss
label_desc: Use image node_id 5 for calling the CenterNetRPNHead obj's underlying member method code with example usage: obj.loss_and_predict(x, batch_data_samples, proposal_cfg) and returns: losses,  predictions