class_docstr: Bridging the Gap Between Anchor-based and Anchor-free Detection via
  Adaptive Training Sample Selection.
  
  ATSS head structure is similar with FCOS, however ATSS use anchor boxes
  and assign label by Adaptive Training Sample Selection instead max-iou.
  
  https://arxiv.org/abs/1912.02424
class_docstr_tok: ["Bridging","the","Gap","Between","Anchor-based","and","Anchor-free","Detection","via","Adaptive","Training","Sample","Selection",".","ATSS","head","structure","is","similar","with","FCOS",",","however","ATSS","use","anchor","boxes","and","assign","label","by","Adaptive","Training","Sample","Selection","instead","max-iou",".","https",":","\/\/arxiv.org\/abs\/1912.02424"]
docstr: Get targets for ATSS head.
  
  This method is almost the same as `AnchorHead.get_targets()`. Besides
  returning the targets as the parent method does, it also returns the
  anchors as the first element of the returned tuple.
docstr_tok: ["Get","targets","for","ATSS","head",".","This","method","is","almost","the","same","as","`","AnchorHead.get_targets","(",")","`",".","Besides","returning","the","targets","as","the","parent","method","does",",","it","also","returns","the","anchors","as","the","first","element","of","the","returned","tuple","."]
code: def get_targets(
      self,
      anchor_list,
      valid_flag_list,
      gt_bboxes_list,
      img_metas,
      gt_bboxes_ignore_list=None,
      gt_labels_list=None,
      label_channels=1,
      unmap_outputs=True,
  ):
      """Get targets for ATSS head.
  
      This method is almost the same as `AnchorHead.get_targets()`. Besides
      returning the targets as the parent method does, it also returns the
      anchors as the first element of the returned tuple.
      """
      num_imgs = len(img_metas)
      assert len(anchor_list) == len(valid_flag_list) == num_imgs
  
      # anchor number of multi levels
      num_level_anchors = [
          anchors.size(0) for anchors in anchor_list[0]
      ]
      num_level_anchors_list = [num_level_anchors] * num_imgs
  
      # concat all level anchors and flags to a single tensor
      for i in range(num_imgs):
          assert len(anchor_list[i]) == len(valid_flag_list[i])
          anchor_list[i] = torch.cat(anchor_list[i])
          valid_flag_list[i] = torch.cat(valid_flag_list[i])
  
      # compute targets for each image
      if gt_bboxes_ignore_list is None:
          gt_bboxes_ignore_list = [None for _ in range(num_imgs)]
      if gt_labels_list is None:
          gt_labels_list = [None for _ in range(num_imgs)]
      (
          all_anchors,
          all_labels,
          all_label_weights,
          all_bbox_targets,
          all_bbox_weights,
          pos_inds_list,
          neg_inds_list,
      ) = multi_apply(
          self._get_target_single,
          anchor_list,
          valid_flag_list,
          num_level_anchors_list,
          gt_bboxes_list,
          gt_bboxes_ignore_list,
          gt_labels_list,
          img_metas,
          label_channels=label_channels,
          unmap_outputs=unmap_outputs,
      )
      # no valid anchors
      if any([labels is None for labels in all_labels]):
          return None
      # sampled anchors of all images
      num_total_pos = sum(
          [max(inds.numel(), 1) for inds in pos_inds_list]
      )
      num_total_neg = sum(
          [max(inds.numel(), 1) for inds in neg_inds_list]
      )
      # split targets to a list w.r.t. multiple levels
      anchors_list = images_to_levels(all_anchors, num_level_anchors)
      labels_list = images_to_levels(all_labels, num_level_anchors)
      label_weights_list = images_to_levels(
          all_label_weights, num_level_anchors
      )
      bbox_targets_list = images_to_levels(
          all_bbox_targets, num_level_anchors
      )
      bbox_weights_list = images_to_levels(
          all_bbox_weights, num_level_anchors
      )
      return (
          anchors_list,
          labels_list,
          label_weights_list,
          bbox_targets_list,
          bbox_weights_list,
          num_total_pos,
          num_total_neg,
      )
  
imports: import torch
  import torch.nn
  from mmcv.cnn import ConvModule, Scale, bias_init_with_prob, normal_init
  from mmcv.runner import force_fp32
  from mmdet.core import anchor_inside_flags, build_assigner, build_sampler, images_to_levels, multi_apply, multiclass_nms, reduce_mean, unmap
  from ..builder import HEADS, build_loss
  from .anchor_head import AnchorHead
label_desc: Use image node_id 11 for calling the ATSSHead obj's underlying member method code with example usage: obj.get_targets(anchor_list, valid_flag_list, gt_bboxes_list, img_metas, gt_bboxes_ignore_list, gt_labels_list, label_channels, unmap_outputs) and returns: anchors_list,  labels_list,  label_weights_list,  bbox_targets_list,  bbox_weights_list,  num_total_pos,  num_total_neg, None