class_docstr: AutoAssignHead head used in AutoAssign.
  
  More details can be found in the `paper
  <https://arxiv.org/abs/2007.03496>`_ .
  
  Args:
      force_topk (bool): Used in center prior initialization to
          handle extremely small gt. Default is False.
      topk (int): The number of points used to calculate the
          center prior when no point falls in gt_bbox. Only work when
          force_topk if True. Defaults to 9.
      pos_loss_weight (float): The loss weight of positive loss
          and with default value 0.25.
      neg_loss_weight (float): The loss weight of negative loss
          and with default value 0.75.
      center_loss_weight (float): The loss weight of center prior
          loss and with default value 0.75.
class_docstr_tok: ["AutoAssignHead","head","used","in","AutoAssign",".","More","details","can","be","found","in","the","`","paper","<","https",":","\/\/arxiv.org\/abs\/2007.03496",">","`","_",".","Args",":","force_topk","(","bool",")",":","Used","in","center","prior","initialization","to","handle","extremely","small","gt",".","Default","is","False",".","topk","(","int",")",":","The","number","of","points","used","to","calculate","the","center","prior","when","no","point","falls","in","gt_bbox",".","Only","work","when","force_topk","if","True",".","Defaults","to","9.","pos_loss_weight","(","float",")",":","The","loss","weight","of","positive","loss","and","with","default","value","0.25.","neg_loss_weight","(","float",")",":","The","loss","weight","of","negative","loss","and","with","default","value","0.75.","center_loss_weight","(","float",")",":","The","loss","weight","of","center","prior","loss","and","with","default","value","0.75","."]
docstr: Calculate the positive loss of all points in gt_bboxes.
  
  Args:
      cls_score (Tensor): All category scores for each point on
          the feature map. The shape is (num_points, num_class).
      objectness (Tensor): Foreground probability of all points,
          has shape (num_points, 1).
      reg_loss (Tensor): The regression loss of each gt_bbox and each
          prediction box, has shape of (num_points, num_gt).
      gt_instances (:obj:`InstanceData`): Ground truth of instance
          annotations. It should includes ``bboxes`` and ``labels``
          attributes.
      center_prior_weights (Tensor): Float tensor with shape
          of (num_points, num_gt). Each value represents
          the center weighting coefficient.
  
  Returns:
      tuple[Tensor]:
  
      - pos_loss (Tensor): The positive loss of all points in the             gt_bboxes.
docstr_tok: ["Calculate","the","positive","loss","of","all","points","in","gt_bboxes",".","Args",":","cls_score","(","Tensor",")",":","All","category","scores","for","each","point","on","the","feature","map",".","The","shape","is","(","num_points",",","num_class",")",".","objectness","(","Tensor",")",":","Foreground","probability","of","all","points",",","has","shape","(","num_points",",","1",")",".","reg_loss","(","Tensor",")",":","The","regression","loss","of","each","gt_bbox","and","each","prediction","box",",","has","shape","of","(","num_points",",","num_gt",")",".","gt_instances","(",":","obj",":","`","InstanceData","`",")",":","Ground","truth","of","instance","annotations",".","It","should","includes","``","bboxes","``","and","``","labels","``","attributes",".","center_prior_weights","(","Tensor",")",":","Float","tensor","with","shape","of","(","num_points",",","num_gt",")",".","Each","value","represents","the","center","weighting","coefficient",".","Returns",":","tuple","[","Tensor","]",":","-","pos_loss","(","Tensor",")",":","The","positive","loss","of","all","points","in","the","gt_bboxes","."]
code: def get_pos_loss_single(
      self,
      cls_score: Tensor,
      objectness: Tensor,
      reg_loss: Tensor,
      gt_instances: InstanceData,
      center_prior_weights: Tensor,
  ) -> Tuple[Tensor]:
      """Calculate the positive loss of all points in gt_bboxes.
  
          Args:
              cls_score (Tensor): All category scores for each point on
                  the feature map. The shape is (num_points, num_class).
              objectness (Tensor): Foreground probability of all points,
                  has shape (num_points, 1).
              reg_loss (Tensor): The regression loss of each gt_bbox and each
                  prediction box, has shape of (num_points, num_gt).
              gt_instances (:obj:`InstanceData`): Ground truth of instance
                  annotations. It should includes ``bboxes`` and ``labels``
                  attributes.
              center_prior_weights (Tensor): Float tensor with shape
                  of (num_points, num_gt). Each value represents
                  the center weighting coefficient.
  
          Returns:
              tuple[Tensor]:
  
              - pos_loss (Tensor): The positive loss of all points in the \
              gt_bboxes.
          """
      gt_labels = gt_instances.labels
      # p_loc: localization confidence
      p_loc = torch.exp(-reg_loss)
      # p_cls: classification confidence
      p_cls = (cls_score * objectness)[:, gt_labels]
      # p_pos: joint confidence indicator
      p_pos = p_cls * p_loc
  
      # 3 is a hyper-parameter to control the contributions of high and
      # low confidence locations towards positive losses.
      confidence_weight = torch.exp(p_pos * 3)
      p_pos_weight = (confidence_weight * center_prior_weights) / (
          (confidence_weight * center_prior_weights).sum(
              0, keepdim=True
          )
      ).clamp(min=EPS)
      reweighted_p_pos = (p_pos * p_pos_weight).sum(0)
      pos_loss = F.binary_cross_entropy(
          reweighted_p_pos,
          torch.ones_like(reweighted_p_pos),
          reduction="none",
      )
      pos_loss = pos_loss.sum() * self.pos_loss_weight
      return (pos_loss,)
  
imports: from typing import Dict, List, Sequence, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Scale
  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.structures.bbox import bbox_overlaps
  from mmdet.utils import InstanceList, OptInstanceList, reduce_mean
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..utils import levels_to_images, multi_apply
  from .fcos_head import FCOSHead
label_desc: Use image node_id 4 for calling the AutoAssignHead obj's underlying member method code with example usage: obj.get_pos_loss_single(cls_score, objectness, reg_loss, gt_instances, center_prior_weights) and returns: pos_loss