class_docstr: YOLOV3Head Paper link: https://arxiv.org/abs/1804.02767.
  
  Args:
      num_classes (int): The number of object classes (w/o background)
      in_channels (List[int]): Number of input channels per scale.
      out_channels (List[int]): The number of output channels per scale
          before the final 1x1 layer. Default: (1024, 512, 256).
      anchor_generator (dict): Config dict for anchor generator
      bbox_coder (dict): Config of bounding box coder.
      featmap_strides (List[int]): The stride of each scale.
          Should be in descending order. Default: (32, 16, 8).
      one_hot_smoother (float): Set a non-zero value to enable label-smooth
          Default: 0.
      conv_cfg (dict): Config dict for convolution layer. Default: None.
      norm_cfg (dict): Dictionary to construct and config norm layer.
          Default: dict(type='BN', requires_grad=True)
      act_cfg (dict): Config dict for activation layer.
          Default: dict(type='LeakyReLU', negative_slope=0.1).
      loss_cls (dict): Config of classification loss.
      loss_conf (dict): Config of confidence loss.
      loss_xy (dict): Config of xy coordinate loss.
      loss_wh (dict): Config of wh coordinate loss.
      train_cfg (dict): Training config of YOLOV3 head. Default: None.
      test_cfg (dict): Testing config of YOLOV3 head. Default: None.
class_docstr_tok: ["YOLOV3Head","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1804.02767",".","Args",":","num_classes","(","int",")",":","The","number","of","object","classes","(","w\/o","background",")","in_channels","(","List","[","int","]",")",":","Number","of","input","channels","per","scale",".","out_channels","(","List","[","int","]",")",":","The","number","of","output","channels","per","scale","before","the","final","1x1","layer",".","Default",":","(","1024",",","512",",","256",")",".","anchor_generator","(","dict",")",":","Config","dict","for","anchor","generator","bbox_coder","(","dict",")",":","Config","of","bounding","box","coder",".","featmap_strides","(","List","[","int","]",")",":","The","stride","of","each","scale",".","Should","be","in","descending","order",".","Default",":","(","32",",","16",",","8",")",".","one_hot_smoother","(","float",")",":","Set","a","non-zero","value","to","enable","label-smooth","Default",":","0.","conv_cfg","(","dict",")",":","Config","dict","for","convolution","layer",".","Default",":","None",".","norm_cfg","(","dict",")",":","Dictionary","to","construct","and","config","norm","layer",".","Default",":","dict","(","type='BN","'",",","requires_grad=True",")","act_cfg","(","dict",")",":","Config","dict","for","activation","layer",".","Default",":","dict","(","type='LeakyReLU","'",",","negative_slope=0.1",")",".","loss_cls","(","dict",")",":","Config","of","classification","loss",".","loss_conf","(","dict",")",":","Config","of","confidence","loss",".","loss_xy","(","dict",")",":","Config","of","xy","coordinate","loss",".","loss_wh","(","dict",")",":","Config","of","wh","coordinate","loss",".","train_cfg","(","dict",")",":","Training","config","of","YOLOV3","head",".","Default",":","None",".","test_cfg","(","dict",")",":","Testing","config","of","YOLOV3","head",".","Default",":","None","."]
code: def __init__(
      self,
      num_classes,
      in_channels,
      out_channels=(1024, 512, 256),
      anchor_generator=dict(
          type="YOLOAnchorGenerator",
          base_sizes=[
              [(116, 90), (156, 198), (373, 326)],
              [(30, 61), (62, 45), (59, 119)],
              [(10, 13), (16, 30), (33, 23)],
          ],
          strides=[32, 16, 8],
      ),
      bbox_coder=dict(type="YOLOBBoxCoder"),
      featmap_strides=[32, 16, 8],
      one_hot_smoother=0.0,
      conv_cfg=None,
      norm_cfg=dict(type="BN", requires_grad=True),
      act_cfg=dict(type="LeakyReLU", negative_slope=0.1),
      loss_cls=dict(
          type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0
      ),
      loss_conf=dict(
          type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0
      ),
      loss_xy=dict(
          type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0
      ),
      loss_wh=dict(type="MSELoss", loss_weight=1.0),
      train_cfg=None,
      test_cfg=None,
  ):
      super(YOLOV3Head, self).__init__()
      # Check params
      assert (
          len(in_channels) == len(out_channels) == len(featmap_strides)
      )
  
      self.num_classes = num_classes
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.featmap_strides = featmap_strides
      self.train_cfg = train_cfg
      self.test_cfg = test_cfg
      if self.train_cfg:
          self.assigner = build_assigner(self.train_cfg.assigner)
          if 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.one_hot_smoother = one_hot_smoother
  
      self.conv_cfg = conv_cfg
      self.norm_cfg = norm_cfg
      self.act_cfg = act_cfg
  
      self.bbox_coder = build_bbox_coder(bbox_coder)
      self.anchor_generator = build_anchor_generator(anchor_generator)
  
      self.loss_cls = build_loss(loss_cls)
      self.loss_conf = build_loss(loss_conf)
      self.loss_xy = build_loss(loss_xy)
      self.loss_wh = build_loss(loss_wh)
      # usually the numbers of anchors for each level are the same
      # except SSD detectors
      self.num_anchors = self.anchor_generator.num_base_anchors[0]
      assert len(self.anchor_generator.num_base_anchors) == len(
          featmap_strides
      )
      self._init_layers()
  
imports: import warnings
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, normal_init
  from mmcv.runner import force_fp32
  from mmdet.core import build_anchor_generator, build_assigner, build_bbox_coder, build_sampler, images_to_levels, multi_apply, multiclass_nms
  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 YOLOV3Head object from inherited base classes: BaseDenseHead, BBoxTestMixin with example: obj = YOLOV3Head(num_classes, in_channels, out_channels, anchor_generator, bbox_coder, featmap_strides, one_hot_smoother, conv_cfg, norm_cfg, act_cfg, loss_cls, loss_conf, loss_xy, loss_wh, train_cfg, test_cfg)