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 negative loss of all points in feature map.
  
  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
          and is shape of (num_points, 1).
      gt_instances (:obj:`InstanceData`): Ground truth of instance
          annotations. It should includes ``bboxes`` and ``labels``
          attributes.
      ious (Tensor): Float tensor with shape of (num_points, num_gt).
          Each value represent the iou of pred_bbox and gt_bboxes.
      inside_gt_bbox_mask (Tensor): Tensor of bool type,
          with shape of (num_points, num_gt), each
          value is used to mark whether this point falls
          within a certain gt.
  
  Returns:
      tuple[Tensor]:
  
      - neg_loss (Tensor): The negative loss of all points in the             feature map.
docstr_tok: ["Calculate","the","negative","loss","of","all","points","in","feature","map",".","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","and","is","shape","of","(","num_points",",","1",")",".","gt_instances","(",":","obj",":","`","InstanceData","`",")",":","Ground","truth","of","instance","annotations",".","It","should","includes","``","bboxes","``","and","``","labels","``","attributes",".","ious","(","Tensor",")",":","Float","tensor","with","shape","of","(","num_points",",","num_gt",")",".","Each","value","represent","the","iou","of","pred_bbox","and","gt_bboxes",".","inside_gt_bbox_mask","(","Tensor",")",":","Tensor","of","bool","type",",","with","shape","of","(","num_points",",","num_gt",")",",","each","value","is","used","to","mark","whether","this","point","falls","within","a","certain","gt",".","Returns",":","tuple","[","Tensor","]",":","-","neg_loss","(","Tensor",")",":","The","negative","loss","of","all","points","in","the","feature","map","."]
code: def get_neg_loss_single(
      self,
      cls_score: Tensor,
      objectness: Tensor,
      gt_instances: InstanceData,
      ious: Tensor,
      inside_gt_bbox_mask: Tensor,
  ) -> Tuple[Tensor]:
      """Calculate the negative loss of all points in feature map.
  
          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
                  and is shape of (num_points, 1).
              gt_instances (:obj:`InstanceData`): Ground truth of instance
                  annotations. It should includes ``bboxes`` and ``labels``
                  attributes.
              ious (Tensor): Float tensor with shape of (num_points, num_gt).
                  Each value represent the iou of pred_bbox and gt_bboxes.
              inside_gt_bbox_mask (Tensor): Tensor of bool type,
                  with shape of (num_points, num_gt), each
                  value is used to mark whether this point falls
                  within a certain gt.
  
          Returns:
              tuple[Tensor]:
  
              - neg_loss (Tensor): The negative loss of all points in the \
              feature map.
          """
      gt_labels = gt_instances.labels
      num_gts = len(gt_labels)
      joint_conf = cls_score * objectness
      p_neg_weight = torch.ones_like(joint_conf)
      if num_gts > 0:
          # the order of dinmension would affect the value of
          # p_neg_weight, we strictly follow the original
          # implementation.
          inside_gt_bbox_mask = inside_gt_bbox_mask.permute(1, 0)
          ious = ious.permute(1, 0)
  
          foreground_idxs = torch.nonzero(
              inside_gt_bbox_mask, as_tuple=True
          )
          temp_weight = 1 / (1 - ious[foreground_idxs]).clamp_(EPS)
  
          def normalize(x):
              return (x - x.min() + EPS) / (x.max() - x.min() + EPS)
  
          for instance_idx in range(num_gts):
              idxs = foreground_idxs[0] == instance_idx
              if idxs.any():
                  temp_weight[idxs] = normalize(temp_weight[idxs])
  
          p_neg_weight[
              foreground_idxs[1], gt_labels[foreground_idxs[0]]
          ] = (1 - temp_weight)
  
      logits = joint_conf * p_neg_weight
      neg_loss = logits**2 * F.binary_cross_entropy(
          logits, torch.zeros_like(logits), reduction="none"
      )
      neg_loss = neg_loss.sum() * self.neg_loss_weight
      return (neg_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 5 for calling the AutoAssignHead obj's underlying member method code with example usage: obj.get_neg_loss_single(cls_score, objectness, gt_instances, ious, inside_gt_bbox_mask) and returns: neg_loss, unknown