class_docstr: YOLOXHead head used in `YOLOX <https://arxiv.org/abs/2107.08430>`_.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      feat_channels (int): Number of hidden channels in stacking convs.
          Defaults to 256
      stacked_convs (int): Number of stacking convs of the head.
          Defaults to (8, 16, 32).
      strides (Sequence[int]): Downsample factor of each feature map.
           Defaults to None.
      use_depthwise (bool): Whether to depthwise separable convolution in
          blocks. Defaults to False.
      dcn_on_last_conv (bool): If true, use dcn in the last layer of
          towers. Defaults to False.
      conv_bias (bool or str): If specified as `auto`, it will be decided by
          the norm_cfg. Bias of conv will be set as True if `norm_cfg` is
          None, otherwise False. Defaults to "auto".
      conv_cfg (:obj:`ConfigDict` or dict, optional): Config dict for
          convolution layer. Defaults to None.
      norm_cfg (:obj:`ConfigDict` or dict): Config dict for normalization
          layer. Defaults to dict(type='BN', momentum=0.03, eps=0.001).
      act_cfg (:obj:`ConfigDict` or dict): Config dict for activation layer.
          Defaults to None.
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of localization loss.
      loss_obj (:obj:`ConfigDict` or dict): Config of objectness loss.
      loss_l1 (:obj:`ConfigDict` or dict): Config of L1 loss.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config of
          anchor head. Defaults to None.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          anchor head. Defaults to None.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or
          list[dict], optional): Initialization config dict.
          Defaults to None.
class_docstr_tok: ["YOLOXHead","head","used","in","`","YOLOX","<","https",":","\/\/arxiv.org\/abs\/2107.08430",">","`","_",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","feat_channels","(","int",")",":","Number","of","hidden","channels","in","stacking","convs",".","Defaults","to","256","stacked_convs","(","int",")",":","Number","of","stacking","convs","of","the","head",".","Defaults","to","(","8",",","16",",","32",")",".","strides","(","Sequence","[","int","]",")",":","Downsample","factor","of","each","feature","map",".","Defaults","to","None",".","use_depthwise","(","bool",")",":","Whether","to","depthwise","separable","convolution","in","blocks",".","Defaults","to","False",".","dcn_on_last_conv","(","bool",")",":","If","true",",","use","dcn","in","the","last","layer","of","towers",".","Defaults","to","False",".","conv_bias","(","bool","or","str",")",":","If","specified","as","`","auto","`",",","it","will","be","decided","by","the","norm_cfg",".","Bias","of","conv","will","be","set","as","True","if","`","norm_cfg","`","is","None",",","otherwise","False",".","Defaults","to","``","auto","''",".","conv_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","dict","for","convolution","layer",".","Defaults","to","None",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","normalization","layer",".","Defaults","to","dict","(","type='BN","'",",","momentum=0.03",",","eps=0.001",")",".","act_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","activation","layer",".","Defaults","to","None",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","localization","loss",".","loss_obj","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","objectness","loss",".","loss_l1","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","L1","loss",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config","of","anchor","head",".","Defaults","to","None",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","anchor","head",".","Defaults","to","None",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","list","[",":","obj",":","`","ConfigDict","`","]","or","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Compute classification, regression, and objectness targets for
  priors in a single image.
  
  Args:
      priors (Tensor): All priors of one image, a 2D-Tensor with shape
          [num_priors, 4] in [cx, xy, stride_w, stride_y] format.
      cls_preds (Tensor): Classification predictions of one image,
          a 2D-Tensor with shape [num_priors, num_classes]
      decoded_bboxes (Tensor): Decoded bboxes predictions of one image,
          a 2D-Tensor with shape [num_priors, 4] in [tl_x, tl_y,
          br_x, br_y] format.
      objectness (Tensor): Objectness predictions of one image,
          a 1D-Tensor with shape [num_priors]
      gt_instances (:obj:`InstanceData`): Ground truth of instance
          annotations. It should includes ``bboxes`` and ``labels``
          attributes.
      img_meta (dict): Meta information for current image.
      gt_instances_ignore (:obj:`InstanceData`, optional): Instances
          to be ignored during training. It includes ``bboxes`` attribute
          data that is ignored during training and testing.
          Defaults to None.
  Returns:
      tuple:
          foreground_mask (list[Tensor]): Binary mask of foreground
          targets.
          cls_target (list[Tensor]): Classification targets of an image.
          obj_target (list[Tensor]): Objectness targets of an image.
          bbox_target (list[Tensor]): BBox targets of an image.
          l1_target (int): BBox L1 targets of an image.
          num_pos_per_img (int): Number of positive samples in an image.
docstr_tok: ["Compute","classification",",","regression",",","and","objectness","targets","for","priors","in","a","single","image",".","Args",":","priors","(","Tensor",")",":","All","priors","of","one","image",",","a","2D-Tensor","with","shape","[","num_priors",",","4","]","in","[","cx",",","xy",",","stride_w",",","stride_y","]","format",".","cls_preds","(","Tensor",")",":","Classification","predictions","of","one","image",",","a","2D-Tensor","with","shape","[","num_priors",",","num_classes","]","decoded_bboxes","(","Tensor",")",":","Decoded","bboxes","predictions","of","one","image",",","a","2D-Tensor","with","shape","[","num_priors",",","4","]","in","[","tl_x",",","tl_y",",","br_x",",","br_y","]","format",".","objectness","(","Tensor",")",":","Objectness","predictions","of","one","image",",","a","1D-Tensor","with","shape","[","num_priors","]","gt_instances","(",":","obj",":","`","InstanceData","`",")",":","Ground","truth","of","instance","annotations",".","It","should","includes","``","bboxes","``","and","``","labels","``","attributes",".","img_meta","(","dict",")",":","Meta","information","for","current","image",".","gt_instances_ignore","(",":","obj",":","`","InstanceData","`",",","optional",")",":","Instances","to","be","ignored","during","training",".","It","includes","``","bboxes","``","attribute","data","that","is","ignored","during","training","and","testing",".","Defaults","to","None",".","Returns",":","tuple",":","foreground_mask","(","list","[","Tensor","]",")",":","Binary","mask","of","foreground","targets",".","cls_target","(","list","[","Tensor","]",")",":","Classification","targets","of","an","image",".","obj_target","(","list","[","Tensor","]",")",":","Objectness","targets","of","an","image",".","bbox_target","(","list","[","Tensor","]",")",":","BBox","targets","of","an","image",".","l1_target","(","int",")",":","BBox","L1","targets","of","an","image",".","num_pos_per_img","(","int",")",":","Number","of","positive","samples","in","an","image","."]
code: def _get_targets_single(
      self,
      priors: Tensor,
      cls_preds: Tensor,
      decoded_bboxes: Tensor,
      objectness: Tensor,
      gt_instances: InstanceData,
      img_meta: dict,
      gt_instances_ignore: Optional[InstanceData] = None,
  ) -> tuple:
      """Compute classification, regression, and objectness targets for
      priors in a single image.
  
      Args:
          priors (Tensor): All priors of one image, a 2D-Tensor with shape
              [num_priors, 4] in [cx, xy, stride_w, stride_y] format.
          cls_preds (Tensor): Classification predictions of one image,
              a 2D-Tensor with shape [num_priors, num_classes]
          decoded_bboxes (Tensor): Decoded bboxes predictions of one image,
              a 2D-Tensor with shape [num_priors, 4] in [tl_x, tl_y,
              br_x, br_y] format.
          objectness (Tensor): Objectness predictions of one image,
              a 1D-Tensor with shape [num_priors]
          gt_instances (:obj:`InstanceData`): Ground truth of instance
              annotations. It should includes ``bboxes`` and ``labels``
              attributes.
          img_meta (dict): Meta information for current image.
          gt_instances_ignore (:obj:`InstanceData`, optional): Instances
              to be ignored during training. It includes ``bboxes`` attribute
              data that is ignored during training and testing.
              Defaults to None.
      Returns:
          tuple:
              foreground_mask (list[Tensor]): Binary mask of foreground
              targets.
              cls_target (list[Tensor]): Classification targets of an image.
              obj_target (list[Tensor]): Objectness targets of an image.
              bbox_target (list[Tensor]): BBox targets of an image.
              l1_target (int): BBox L1 targets of an image.
              num_pos_per_img (int): Number of positive samples in an image.
      """
  
      num_priors = priors.size(0)
      num_gts = len(gt_instances)
      # No target
      if num_gts == 0:
          cls_target = cls_preds.new_zeros((0, self.num_classes))
          bbox_target = cls_preds.new_zeros((0, 4))
          l1_target = cls_preds.new_zeros((0, 4))
          obj_target = cls_preds.new_zeros((num_priors, 1))
          foreground_mask = cls_preds.new_zeros(num_priors).bool()
          return (
              foreground_mask,
              cls_target,
              obj_target,
              bbox_target,
              l1_target,
              0,
          )
  
      # YOLOX uses center priors with 0.5 offset to assign targets,
      # but use center priors without offset to regress bboxes.
      offset_priors = torch.cat(
          [priors[:, :2] + priors[:, 2:] * 0.5, priors[:, 2:]], dim=-1
      )
  
      scores = cls_preds.sigmoid() * objectness.unsqueeze(1).sigmoid()
      pred_instances = InstanceData(
          bboxes=decoded_bboxes,
          scores=scores.sqrt_(),
          priors=offset_priors,
      )
      assign_result = self.assigner.assign(
          pred_instances=pred_instances,
          gt_instances=gt_instances,
          gt_instances_ignore=gt_instances_ignore,
      )
  
      sampling_result = self.sampler.sample(
          assign_result, pred_instances, gt_instances
      )
      pos_inds = sampling_result.pos_inds
      num_pos_per_img = pos_inds.size(0)
  
      pos_ious = assign_result.max_overlaps[pos_inds]
      # IOU aware classification score
      cls_target = F.one_hot(
          sampling_result.pos_gt_labels, self.num_classes
      ) * pos_ious.unsqueeze(-1)
      obj_target = torch.zeros_like(objectness).unsqueeze(-1)
      obj_target[pos_inds] = 1
      bbox_target = sampling_result.pos_gt_bboxes
      l1_target = cls_preds.new_zeros((num_pos_per_img, 4))
      if self.use_l1:
          l1_target = self._get_l1_target(
              l1_target, bbox_target, priors[pos_inds]
          )
      foreground_mask = torch.zeros_like(objectness).to(torch.bool)
      foreground_mask[pos_inds] = 1
      return (
          foreground_mask,
          cls_target,
          obj_target,
          bbox_target,
          l1_target,
          num_pos_per_img,
      )
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
  from mmcv.ops.nms import batched_nms
  from mmengine.config import ConfigDict
  from mmengine.model import bias_init_with_prob
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import bbox_xyxy_to_cxcywh
  from mmdet.utils import ConfigType, OptConfigType, OptInstanceList, OptMultiConfig, reduce_mean
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..task_modules.samplers import PseudoSampler
  from ..utils import multi_apply
  from .base_dense_head import BaseDenseHead
label_desc: Use image node_id 12 for calling the YOLOXHead obj's underlying member method code with example usage: obj._get_targets_single(priors, cls_preds, decoded_bboxes, objectness, gt_instances, img_meta, gt_instances_ignore) and returns: foreground_mask,  cls_target,  obj_target,  bbox_target,  l1_target,  num_pos_per_img, foreground_mask,  cls_target,  obj_target,  bbox_target,  l1_target,  int