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 (tuple[tuple[int, int]]): Regress range of multiple
          level points.
      center_sampling (bool): If true, use center sampling. Default: False.
      center_sample_radius (float): Radius of center sampling. Default: 1.5.
      sync_num_pos (bool): If true, synchronize the number of positive
          examples across GPUs. Default: True
      gradient_mul (float): The multiplier to gradients from bbox refinement
          and recognition. Default: 0.1.
      bbox_norm_type (str): The bbox normalization type, 'reg_denom' or
          'stride'. Default: reg_denom
      loss_cls_fl (dict): Config of focal loss.
      use_vfl (bool): If true, use varifocal loss for training.
          Default: True.
      loss_cls (dict): Config of varifocal loss.
      loss_bbox (dict): Config of localization loss, GIoU Loss.
      loss_bbox (dict): Config of localization refinement loss, GIoU Loss.
      norm_cfg (dict): dictionary to construct and config norm layer.
          Default: norm_cfg=dict(type='GN', num_groups=32,
          requires_grad=True).
      use_atss (bool): If true, use ATSS to define positive/negative
          examples. Default: True.
      anchor_generator (dict): Config of anchor generator for ATSS.
  
  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 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).
      gt_bboxes (list[Tensor]): Ground truth bboxes of each image,
          each has shape (num_gt, 4).
      gt_labels (list[Tensor]): Ground truth labels of each box,
          each has shape (num_gt,).
      img_metas (list[dict]): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      gt_bboxes_ignore (None | Tensor): Ground truth bboxes to be
          ignored, shape (num_ignored_gts, 4). Default: None.
  
  Returns:
      tuple:
          labels_list (list[Tensor]): Labels of each level.
          label_weights (Tensor): Label weights of all levels.
          bbox_targets_list (list[Tensor]): Regression targets of each
              level, (l, t, r, b).
          bbox_weights (Tensor): Bbox weights of all levels.
docstr_tok: ["A","wrapper","for","computing","ATSS","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",")",".","gt_bboxes","(","list","[","Tensor","]",")",":","Ground","truth","bboxes","of","each","image",",","each","has","shape","(","num_gt",",","4",")",".","gt_labels","(","list","[","Tensor","]",")",":","Ground","truth","labels","of","each","box",",","each","has","shape","(","num_gt",",",")",".","img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","gt_bboxes_ignore","(","None","|","Tensor",")",":","Ground","truth","bboxes","to","be","ignored",",","shape","(","num_ignored_gts",",","4",")",".","Default",":","None",".","Returns",":","tuple",":","labels_list","(","list","[","Tensor","]",")",":","Labels","of","each","level",".","label_weights","(","Tensor",")",":","Label","weights","of","all","levels",".","bbox_targets_list","(","list","[","Tensor","]",")",":","Regression","targets","of","each","level",",","(","l",",","t",",","r",",","b",")",".","bbox_weights","(","Tensor",")",":","Bbox","weights","of","all","levels","."]
code: def get_atss_targets(
      self,
      cls_scores,
      mlvl_points,
      gt_bboxes,
      gt_labels,
      img_metas,
      gt_bboxes_ignore=None,
  ):
      """A wrapper for computing ATSS 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).
          gt_bboxes (list[Tensor]): Ground truth bboxes of each image,
              each has shape (num_gt, 4).
          gt_labels (list[Tensor]): Ground truth labels of each box,
              each has shape (num_gt,).
          img_metas (list[dict]): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          gt_bboxes_ignore (None | Tensor): Ground truth bboxes to be
              ignored, shape (num_ignored_gts, 4). Default: None.
  
      Returns:
          tuple:
              labels_list (list[Tensor]): Labels of each level.
              label_weights (Tensor): Label weights of all levels.
              bbox_targets_list (list[Tensor]): Regression targets of each
                  level, (l, t, r, b).
              bbox_weights (Tensor): Bbox weights of all levels.
      """
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
      assert len(featmap_sizes) == self.anchor_generator.num_levels
  
      device = cls_scores[0].device
      anchor_list, valid_flag_list = self.get_anchors(
          featmap_sizes, img_metas, device=device
      )
      label_channels = (
          self.cls_out_channels if self.use_sigmoid_cls else 1
      )
  
      cls_reg_targets = ATSSHead.get_targets(
          self,
          anchor_list,
          valid_flag_list,
          gt_bboxes,
          img_metas,
          gt_bboxes_ignore_list=gt_bboxes_ignore,
          gt_labels_list=gt_labels,
          label_channels=label_channels,
          unmap_outputs=True,
      )
      if cls_reg_targets is None:
          return None
  
      (
          anchor_list,
          labels_list,
          label_weights_list,
          bbox_targets_list,
          bbox_weights_list,
          num_total_pos,
          num_total_neg,
      ) = cls_reg_targets
  
      bbox_targets_list = [
          bbox_targets.reshape(-1, 4)
          for bbox_targets in bbox_targets_list
      ]
  
      num_imgs = len(img_metas)
      # transform bbox_targets (x1, y1, x2, y2) into (l, t, r, b) format
      bbox_targets_list = self.transform_bbox_targets(
          bbox_targets_list, mlvl_points, num_imgs
      )
  
      labels_list = [labels.reshape(-1) for labels in labels_list]
      label_weights_list = [
          label_weights.reshape(-1)
          for label_weights in label_weights_list
      ]
      bbox_weights_list = [
          bbox_weights.reshape(-1) for bbox_weights in bbox_weights_list
      ]
      label_weights = torch.cat(label_weights_list)
      bbox_weights = torch.cat(bbox_weights_list)
      return labels_list, label_weights, bbox_targets_list, bbox_weights
  
imports: import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
  from mmcv.ops import DeformConv2d
  from mmcv.runner import force_fp32
  from mmdet.core import bbox2distance, bbox_overlaps, build_anchor_generator, build_assigner, build_sampler, distance2bbox, multi_apply, multiclass_nms, reduce_mean
  from ..builder import HEADS, build_loss
  from .atss_head import ATSSHead
  from .fcos_head import FCOSHead
label_desc: Use image node_id 14 for calling the VFNetHead obj's underlying member method code with example usage: obj.get_atss_targets(cls_scores, mlvl_points, gt_bboxes, gt_labels, img_metas, gt_bboxes_ignore) and returns: labels_list,  label_weights,  bbox_targets_list,  bbox_weights, None