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","."]
docstr: Compute loss of the head.
  
  Args:
      pred_maps (list[Tensor]): Prediction map for each scale level,
          shape (N, num_anchors * num_attrib, H, W)
      gt_bboxes (list[Tensor]): Ground truth bboxes for each image with
          shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
      gt_labels (list[Tensor]): class indices corresponding to each box
      img_metas (list[dict]): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      gt_bboxes_ignore (None | list[Tensor]): specify which bounding
          boxes can be ignored when computing the loss.
  
  Returns:
      dict[str, Tensor]: A dictionary of loss components.
docstr_tok: ["Compute","loss","of","the","head",".","Args",":","pred_maps","(","list","[","Tensor","]",")",":","Prediction","map","for","each","scale","level",",","shape","(","N",",","num_anchors","*","num_attrib",",","H",",","W",")","gt_bboxes","(","list","[","Tensor","]",")",":","Ground","truth","bboxes","for","each","image","with","shape","(","num_gts",",","4",")","in","[","tl_x",",","tl_y",",","br_x",",","br_y","]","format",".","gt_labels","(","list","[","Tensor","]",")",":","class","indices","corresponding","to","each","box","img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","gt_bboxes_ignore","(","None","|","list","[","Tensor","]",")",":","specify","which","bounding","boxes","can","be","ignored","when","computing","the","loss",".","Returns",":","dict","[","str",",","Tensor","]",":","A","dictionary","of","loss","components","."]
code: def loss(
      self,
      pred_maps,
      gt_bboxes,
      gt_labels,
      img_metas,
      gt_bboxes_ignore=None,
  ):
      """Compute loss of the head.
  
      Args:
          pred_maps (list[Tensor]): Prediction map for each scale level,
              shape (N, num_anchors * num_attrib, H, W)
          gt_bboxes (list[Tensor]): Ground truth bboxes for each image with
              shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
          gt_labels (list[Tensor]): class indices corresponding to each box
          img_metas (list[dict]): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          gt_bboxes_ignore (None | list[Tensor]): specify which bounding
              boxes can be ignored when computing the loss.
  
      Returns:
          dict[str, Tensor]: A dictionary of loss components.
      """
      num_imgs = len(img_metas)
      device = pred_maps[0][0].device
  
      featmap_sizes = [
          pred_maps[i].shape[-2:] for i in range(self.num_levels)
      ]
      multi_level_anchors = self.anchor_generator.grid_anchors(
          featmap_sizes, device
      )
      anchor_list = [multi_level_anchors for _ in range(num_imgs)]
  
      responsible_flag_list = []
      for img_id in range(len(img_metas)):
          responsible_flag_list.append(
              self.anchor_generator.responsible_flags(
                  featmap_sizes, gt_bboxes[img_id], device
              )
          )
  
      target_maps_list, neg_maps_list = self.get_targets(
          anchor_list, responsible_flag_list, gt_bboxes, gt_labels
      )
  
      losses_cls, losses_conf, losses_xy, losses_wh = multi_apply(
          self.loss_single, pred_maps, target_maps_list, neg_maps_list
      )
  
      return dict(
          loss_cls=losses_cls,
          loss_conf=losses_conf,
          loss_xy=losses_xy,
          loss_wh=losses_wh,
      )
  
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 9 for calling the YOLOV3Head obj's underlying member method code with example usage: obj.loss(pred_maps, gt_bboxes, gt_labels, img_metas, gt_bboxes_ignore) and returns: dict