class_docstr: Head of `VarifocalNet (VFNet): An IoU-aware Dense Object
  Detector.<https://arxiv.org/abs/2008.13367>`_.
  
  The VFNet predicts IoU-aware classification scores which mix the
  object presence confidence and object localization accuracy as the
  detection score. It is built on the FCOS architecture and uses ATSS
  for defining positive/negative training examples. The VFNet is trained
  with Varifocal Loss and empolys star-shaped deformable convolution to
  extract features for a bbox.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      regress_ranges (Sequence[Tuple[int, int]]): Regress range of multiple
          level points.
      center_sampling (bool): If true, use center sampling. Defaults to False.
      center_sample_radius (float): Radius of center sampling. Defaults to 1.5.
      sync_num_pos (bool): If true, synchronize the number of positive
          examples across GPUs. Defaults to True
      gradient_mul (float): The multiplier to gradients from bbox refinement
          and recognition. Defaults to 0.1.
      bbox_norm_type (str): The bbox normalization type, 'reg_denom' or
          'stride'. Defaults to reg_denom
      loss_cls_fl (:obj:`ConfigDict` or dict): Config of focal loss.
      use_vfl (bool): If true, use varifocal loss for training.
          Defaults to True.
      loss_cls (:obj:`ConfigDict` or dict): Config of varifocal loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of localization loss,
          GIoU Loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of localization
          refinement loss, GIoU Loss.
      norm_cfg (:obj:`ConfigDict` or dict): dictionary to construct and
          config norm layer. Defaults to norm_cfg=dict(type='GN',
          num_groups=32, requires_grad=True).
      use_atss (bool): If true, use ATSS to define positive/negative
          examples. Defaults to True.
      anchor_generator (:obj:`ConfigDict` or dict): Config of anchor
          generator for ATSS.
      init_cfg (:obj:`ConfigDict` or dict or list[dict] or
          list[:obj:`ConfigDict`]): Initialization config dict.
  
  Example:
      >>> self = VFNetHead(11, 7)
      >>> feats = [torch.rand(1, 7, s, s) for s in [4, 8, 16, 32, 64]]
      >>> cls_score, bbox_pred, bbox_pred_refine= self.forward(feats)
      >>> assert len(cls_score) == len(self.scales)
class_docstr_tok: ["Head","of","`","VarifocalNet","(","VFNet",")",":","An","IoU-aware","Dense","Object","Detector.","<","https",":","\/\/arxiv.org\/abs\/2008.13367",">","`","_",".","The","VFNet","predicts","IoU-aware","classification","scores","which","mix","the","object","presence","confidence","and","object","localization","accuracy","as","the","detection","score",".","It","is","built","on","the","FCOS","architecture","and","uses","ATSS","for","defining","positive\/negative","training","examples",".","The","VFNet","is","trained","with","Varifocal","Loss","and","empolys","star-shaped","deformable","convolution","to","extract","features","for","a","bbox",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","regress_ranges","(","Sequence","[","Tuple","[","int",",","int","]","]",")",":","Regress","range","of","multiple","level","points",".","center_sampling","(","bool",")",":","If","true",",","use","center","sampling",".","Defaults","to","False",".","center_sample_radius","(","float",")",":","Radius","of","center","sampling",".","Defaults","to","1.5.","sync_num_pos","(","bool",")",":","If","true",",","synchronize","the","number","of","positive","examples","across","GPUs",".","Defaults","to","True","gradient_mul","(","float",")",":","The","multiplier","to","gradients","from","bbox","refinement","and","recognition",".","Defaults","to","0.1.","bbox_norm_type","(","str",")",":","The","bbox","normalization","type",",","'reg_denom","'","or","'stride","'",".","Defaults","to","reg_denom","loss_cls_fl","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","focal","loss",".","use_vfl","(","bool",")",":","If","true",",","use","varifocal","loss","for","training",".","Defaults","to","True",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","varifocal","loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","localization","loss",",","GIoU","Loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","localization","refinement","loss",",","GIoU","Loss",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","dictionary","to","construct","and","config","norm","layer",".","Defaults","to","norm_cfg=dict","(","type='GN","'",",","num_groups=32",",","requires_grad=True",")",".","use_atss","(","bool",")",":","If","true",",","use","ATSS","to","define","positive\/negative","examples",".","Defaults","to","True",".","anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","anchor","generator","for","ATSS",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[","dict","]","or","list","[",":","obj",":","`","ConfigDict","`","]",")",":","Initialization","config","dict",".","Example",":",">",">",">","self","=","VFNetHead","(","11",",","7",")",">",">",">","feats","=","[","torch.rand","(","1",",","7",",","s",",","s",")","for","s","in","[","4",",","8",",","16",",","32",",","64","]","]",">",">",">","cls_score",",","bbox_pred",",","bbox_pred_refine=","self.forward","(","feats",")",">",">",">","assert","len","(","cls_score",")","==","len","(","self.scales",")"]
docstr: A wrapper for computing ATSS and FCOS targets for points in multiple
  images.
  
  Args:
      cls_scores (list[Tensor]): Box iou-aware scores for each scale
          level with shape (N, num_points * num_classes, H, W).
      mlvl_points (list[Tensor]): Points of each fpn level, each has
          shape (num_points, 2).
      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:
      tuple:
  
      - labels_list (list[Tensor]): Labels of each level.
      - label_weights (Tensor/None): Label weights of all levels.
      - bbox_targets_list (list[Tensor]): Regression targets of each
        level, (l, t, r, b).
      - bbox_weights (Tensor/None): Bbox weights of all levels.
docstr_tok: ["A","wrapper","for","computing","ATSS","and","FCOS","targets","for","points","in","multiple","images",".","Args",":","cls_scores","(","list","[","Tensor","]",")",":","Box","iou-aware","scores","for","each","scale","level","with","shape","(","N",",","num_points","*","num_classes",",","H",",","W",")",".","mlvl_points","(","list","[","Tensor","]",")",":","Points","of","each","fpn","level",",","each","has","shape","(","num_points",",","2",")",".","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",":","tuple",":","-","labels_list","(","list","[","Tensor","]",")",":","Labels","of","each","level",".","-","label_weights","(","Tensor\/None",")",":","Label","weights","of","all","levels",".","-","bbox_targets_list","(","list","[","Tensor","]",")",":","Regression","targets","of","each","level",",","(","l",",","t",",","r",",","b",")",".","-","bbox_weights","(","Tensor\/None",")",":","Bbox","weights","of","all","levels","."]
code: def get_targets(
      self,
      cls_scores: List[Tensor],
      mlvl_points: List[Tensor],
      batch_gt_instances: InstanceList,
      batch_img_metas: List[dict],
      batch_gt_instances_ignore: OptInstanceList = None,
  ) -> tuple:
      """A wrapper for computing ATSS and FCOS targets for points in multiple
      images.
  
      Args:
          cls_scores (list[Tensor]): Box iou-aware scores for each scale
              level with shape (N, num_points * num_classes, H, W).
          mlvl_points (list[Tensor]): Points of each fpn level, each has
              shape (num_points, 2).
          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:
          tuple:
  
          - labels_list (list[Tensor]): Labels of each level.
          - label_weights (Tensor/None): Label weights of all levels.
          - bbox_targets_list (list[Tensor]): Regression targets of each
            level, (l, t, r, b).
          - bbox_weights (Tensor/None): Bbox weights of all levels.
      """
      if self.use_atss:
          return self.get_atss_targets(
              cls_scores,
              mlvl_points,
              batch_gt_instances,
              batch_img_metas,
              batch_gt_instances_ignore,
          )
      else:
          self.norm_on_bbox = False
          return self.get_fcos_targets(mlvl_points, batch_gt_instances)
  
imports: from typing import List, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, Scale
  from mmcv.ops import DeformConv2d
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import bbox_overlaps
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptInstanceList, RangeType, reduce_mean
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..task_modules.samplers import PseudoSampler
  from ..utils import multi_apply
  from .atss_head import ATSSHead
  from .fcos_head import FCOSHead
label_desc: Use image node_id 7 for calling the VFNetHead obj's underlying member method code with example usage: obj.get_targets(cls_scores, mlvl_points, batch_gt_instances, batch_img_metas, batch_gt_instances_ignore) and returns: self, self