class_docstr: Anchor-based head (RPN, RetinaNet, SSD, etc.).
  
  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. Used in child classes.
      anchor_generator (dict): Config dict for anchor generator
      bbox_coder (dict): Config of bounding box coder.
      reg_decoded_bbox (bool): If true, the regression loss would be
          applied on decoded bounding boxes. Default: False
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of localization loss.
      train_cfg (dict): Training config of anchor head.
      test_cfg (dict): Testing config of anchor head.
code: def __init__(
      self,
      num_classes,
      in_channels,
      feat_channels=256,
      anchor_generator=dict(
          type="AnchorGenerator",
          scales=[8, 16, 32],
          ratios=[0.5, 1.0, 2.0],
          strides=[4, 8, 16, 32, 64],
      ),
      bbox_coder=dict(
          type="DeltaXYWHBBoxCoder",
          clip_border=True,
          target_means=(0.0, 0.0, 0.0, 0.0),
          target_stds=(1.0, 1.0, 1.0, 1.0),
      ),
      reg_decoded_bbox=False,
      loss_cls=dict(
          type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0
      ),
      loss_bbox=dict(
          type="SmoothL1Loss", beta=1.0 / 9.0, loss_weight=1.0
      ),
      train_cfg=None,
      test_cfg=None,
  ):
      super(AnchorHead, self).__init__()
      self.in_channels = in_channels
      self.num_classes = num_classes
      self.feat_channels = feat_channels
      self.use_sigmoid_cls = loss_cls.get("use_sigmoid", False)
      # TODO better way to determine whether sample or not
      self.sampling = loss_cls["type"] not in [
          "FocalLoss",
          "GHMC",
          "QualityFocalLoss",
      ]
      if self.use_sigmoid_cls:
          self.cls_out_channels = num_classes
      else:
          self.cls_out_channels = num_classes + 1
  
      if self.cls_out_channels <= 0:
          raise ValueError(f"num_classes={num_classes} is too small")
      self.reg_decoded_bbox = reg_decoded_bbox
  
      self.bbox_coder = build_bbox_coder(bbox_coder)
      self.loss_cls = build_loss(loss_cls)
      self.loss_bbox = build_loss(loss_bbox)
      self.train_cfg = train_cfg
      self.test_cfg = test_cfg
      if self.train_cfg:
          self.assigner = build_assigner(self.train_cfg.assigner)
          # use PseudoSampler when sampling is False
          if self.sampling and hasattr(self.train_cfg, "sampler"):
              sampler_cfg = self.train_cfg.sampler
          else:
              sampler_cfg = dict(type="PseudoSampler")
          self.sampler = build_sampler(sampler_cfg, context=self)
      self.fp16_enabled = False
  
      self.anchor_generator = build_anchor_generator(anchor_generator)
      # usually the numbers of anchors for each level are the same
      # except SSD detectors
      self.num_anchors = self.anchor_generator.num_base_anchors[0]
      self._init_layers()
  
imports: import torch
  import torch.nn
  from mmcv.cnn import normal_init
  from mmcv.runner import force_fp32
  from mmdet.core import anchor_inside_flags, build_anchor_generator, build_assigner, build_bbox_coder, build_sampler, images_to_levels, multi_apply, multiclass_nms, unmap
  from ..builder import HEADS, build_loss
  from .base_dense_head import BaseDenseHead
  from .dense_test_mixins import BBoxTestMixin
label_desc: Use image node_id 1 to create a new AnchorHead object from inherited base classes: BaseDenseHead, BBoxTestMixin with example: obj = AnchorHead(num_classes, in_channels, feat_channels, anchor_generator, bbox_coder, reg_decoded_bbox, loss_cls, loss_bbox, train_cfg, test_cfg)