class_docstr: Anchor-free head used in `FCOS <https://arxiv.org/abs/1904.01355>`_.
  
  The FCOS head does not use anchor boxes. Instead bounding boxes are
  predicted at each pixel and a centerness measure is used to suppress
  low-quality predictions.
  Here norm_on_bbox, centerness_on_reg, dcn_on_last_conv are training
  tricks used in official repo, which will bring remarkable mAP gains
  of up to 4.9. Please see https://github.com/tianzhi0549/FCOS for
  more detail.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      strides (Sequence[int] or Sequence[Tuple[int, int]]): Strides of points
          in multiple feature levels. Defaults to (4, 8, 16, 32, 64).
      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.
      norm_on_bbox (bool): If true, normalize the regression targets with
          FPN strides. Defaults to False.
      centerness_on_reg (bool): If true, position centerness on the
          regress branch. Please refer to https://github.com/tianzhi0549/FCOS/issues/89#issuecomment-516877042.
          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".
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of localization loss.
      loss_centerness (:obj:`ConfigDict`, or dict): Config of centerness
          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)``.
      cls_predictor_cfg (:obj:`ConfigDict` or dict): dictionary to construct and
          config conv_cls. Defaults to None.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict]): Initialization config dict.
  
  Example:
      >>> self = FCOSHead(11, 7)
      >>> feats = [torch.rand(1, 7, s, s) for s in [4, 8, 16, 32, 64]]
      >>> cls_score, bbox_pred, centerness = self.forward(feats)
      >>> assert len(cls_score) == len(self.scales)
class_docstr_tok: ["Anchor-free","head","used","in","`","FCOS","<","https",":","\/\/arxiv.org\/abs\/1904.01355",">","`","_",".","The","FCOS","head","does","not","use","anchor","boxes",".","Instead","bounding","boxes","are","predicted","at","each","pixel","and","a","centerness","measure","is","used","to","suppress","low-quality","predictions",".","Here","norm_on_bbox",",","centerness_on_reg",",","dcn_on_last_conv","are","training","tricks","used","in","official","repo",",","which","will","bring","remarkable","mAP","gains","of","up","to","4.9",".","Please","see","https",":","\/\/github.com\/tianzhi0549\/FCOS","for","more","detail",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","strides","(","Sequence","[","int","]","or","Sequence","[","Tuple","[","int",",","int","]","]",")",":","Strides","of","points","in","multiple","feature","levels",".","Defaults","to","(","4",",","8",",","16",",","32",",","64",")",".","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.","norm_on_bbox","(","bool",")",":","If","true",",","normalize","the","regression","targets","with","FPN","strides",".","Defaults","to","False",".","centerness_on_reg","(","bool",")",":","If","true",",","position","centerness","on","the","regress","branch",".","Please","refer","to","https",":","\/\/github.com\/tianzhi0549\/FCOS\/issues\/89","#","issuecomment-516877042",".","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","''",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","localization","loss",".","loss_centerness","(",":","obj",":","`","ConfigDict","`",",","or","dict",")",":","Config","of","centerness","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",")","``",".","cls_predictor_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","dictionary","to","construct","and","config","conv_cls",".","Defaults","to","None",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",")",":","Initialization","config","dict",".","Example",":",">",">",">","self","=","FCOSHead","(","11",",","7",")",">",">",">","feats","=","[","torch.rand","(","1",",","7",",","s",",","s",")","for","s","in","[","4",",","8",",","16",",","32",",","64","]","]",">",">",">","cls_score",",","bbox_pred",",","centerness","=","self.forward","(","feats",")",">",">",">","assert","len","(","cls_score",")","==","len","(","self.scales",")"]
docstr: Compute regression, classification and centerness targets for points
  in multiple images.
  
  Args:
      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.
  
  Returns:
      tuple: Targets of each level.
  
      - concat_lvl_labels (list[Tensor]): Labels of each level.
      - concat_lvl_bbox_targets (list[Tensor]): BBox targets of each             level.
docstr_tok: ["Compute","regression",",","classification","and","centerness","targets","for","points","in","multiple","images",".","Args",":","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",".","Returns",":","tuple",":","Targets","of","each","level",".","-","concat_lvl_labels","(","list","[","Tensor","]",")",":","Labels","of","each","level",".","-","concat_lvl_bbox_targets","(","list","[","Tensor","]",")",":","BBox","targets","of","each","level","."]
code: def get_targets(
      self, points: List[Tensor], batch_gt_instances: InstanceList
  ) -> Tuple[List[Tensor], List[Tensor]]:
      """Compute regression, classification and centerness targets for points
          in multiple images.
  
          Args:
              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.
  
          Returns:
              tuple: Targets of each level.
  
              - concat_lvl_labels (list[Tensor]): Labels of each level.
              - concat_lvl_bbox_targets (list[Tensor]): BBox targets of each \
              level.
          """
      assert len(points) == len(self.regress_ranges)
      num_levels = len(points)
      # expand regress ranges to align with points
      expanded_regress_ranges = [
          points[i]
          .new_tensor(self.regress_ranges[i])[None]
          .expand_as(points[i])
          for i in range(num_levels)
      ]
      # concat all levels points and regress ranges
      concat_regress_ranges = torch.cat(expanded_regress_ranges, dim=0)
      concat_points = torch.cat(points, dim=0)
  
      # the number of points per img, per lvl
      num_points = [center.size(0) for center in points]
  
      # get labels and bbox_targets of each image
      labels_list, bbox_targets_list = multi_apply(
          self._get_targets_single,
          batch_gt_instances,
          points=concat_points,
          regress_ranges=concat_regress_ranges,
          num_points_per_lvl=num_points,
      )
  
      # split to per img, per level
      labels_list = [
          labels.split(num_points, 0) for labels in labels_list
      ]
      bbox_targets_list = [
          bbox_targets.split(num_points, 0)
          for bbox_targets in bbox_targets_list
      ]
  
      # concat per level image
      concat_lvl_labels = []
      concat_lvl_bbox_targets = []
      for i in range(num_levels):
          concat_lvl_labels.append(
              torch.cat([labels[i] for labels in labels_list])
          )
          bbox_targets = torch.cat(
              [bbox_targets[i] for bbox_targets in bbox_targets_list]
          )
          if self.norm_on_bbox:
              bbox_targets = bbox_targets / self.strides[i]
          concat_lvl_bbox_targets.append(bbox_targets)
      return concat_lvl_labels, concat_lvl_bbox_targets
  
imports: from typing import Dict, List, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import Scale
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.layers import NormedConv2d
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptInstanceList, RangeType, reduce_mean
  from ..utils import multi_apply
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 6 for calling the FCOSHead obj's underlying member method code with example usage: obj.get_targets(points, batch_gt_instances) and returns: concat_lvl_labels,  concat_lvl_bbox_targets