class_docstr: Side-Aware Boundary Localization (SABL) for RetinaNet.
  
  The anchor generation, assigning and sampling in SABLRetinaHead
  are the same as GuidedAnchorHead for guided anchoring.
  
  Please refer to https://arxiv.org/abs/1912.04260 for more details.
  
  Args:
      num_classes (int): Number of classes.
      in_channels (int): Number of channels in the input feature map.
      stacked_convs (int): Number of Convs for classification             and regression branches. Defaults to 4.
      feat_channels (int): Number of hidden channels.             Defaults to 256.
      approx_anchor_generator (dict): Config dict for approx generator.
      square_anchor_generator (dict): Config dict for square generator.
      conv_cfg (dict): Config dict for ConvModule. Defaults to None.
      norm_cfg (dict): Config dict for Norm Layer. Defaults to None.
      bbox_coder (dict): Config dict for bbox coder.
      reg_decoded_bbox (bool): Whether to regress decoded bbox.             Defaults to False.
      train_cfg (dict): Training config of SABLRetinaHead.
      test_cfg (dict): Testing config of SABLRetinaHead.
      loss_cls (dict): Config of classification loss.
      loss_bbox_cls (dict): Config of classification loss for bbox branch.
      loss_bbox_reg (dict): Config of regression loss for bbox branch.
code: def loss(
      self,
      cls_scores,
      bbox_preds,
      gt_bboxes,
      gt_labels,
      img_metas,
      gt_bboxes_ignore=None,
  ):
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
      assert (
          len(featmap_sizes) == self.approx_anchor_generator.num_levels
      )
  
      device = cls_scores[0].device
  
      # get sampled approxes
      (
          approxs_list,
          inside_flag_list,
      ) = GuidedAnchorHead.get_sampled_approxs(
          self, featmap_sizes, img_metas, device=device
      )
  
      square_list = self.get_anchors(
          featmap_sizes, img_metas, device=device
      )
  
      label_channels = (
          self.cls_out_channels if self.use_sigmoid_cls else 1
      )
  
      cls_reg_targets = self.get_target(
          approxs_list,
          inside_flag_list,
          square_list,
          gt_bboxes,
          img_metas,
          gt_bboxes_ignore_list=gt_bboxes_ignore,
          gt_labels_list=gt_labels,
          label_channels=label_channels,
          sampling=self.sampling,
      )
      if cls_reg_targets is None:
          return None
      (
          labels_list,
          label_weights_list,
          bbox_cls_targets_list,
          bbox_cls_weights_list,
          bbox_reg_targets_list,
          bbox_reg_weights_list,
          num_total_pos,
          num_total_neg,
      ) = cls_reg_targets
      num_total_samples = (
          num_total_pos + num_total_neg
          if self.sampling
          else num_total_pos
      )
      losses_cls, losses_bbox_cls, losses_bbox_reg = multi_apply(
          self.loss_single,
          cls_scores,
          bbox_preds,
          labels_list,
          label_weights_list,
          bbox_cls_targets_list,
          bbox_cls_weights_list,
          bbox_reg_targets_list,
          bbox_reg_weights_list,
          num_total_samples=num_total_samples,
      )
      return dict(
          loss_cls=losses_cls,
          loss_bbox_cls=losses_bbox_cls,
          loss_bbox_reg=losses_bbox_reg,
      )
  
imports: import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule, bias_init_with_prob, 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, unmap
  from ..builder import HEADS, build_loss
  from .base_dense_head import BaseDenseHead
  from .guided_anchor_head import GuidedAnchorHead
label_desc: Use image node_id 10 for calling the SABLRetinaHead obj's underlying member method code with example usage: obj.loss(cls_scores, bbox_preds, gt_bboxes, gt_labels, img_metas, gt_bboxes_ignore) and returns: dict, None