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.
docstr: Compute bucketing targets.
  Args:
      approx_list (list[list]): Multi level approxs of each image.
      inside_flag_list (list[list]): Multi level inside flags of each
          image.
      square_list (list[list]): Multi level squares of each image.
      gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image.
      img_metas (list[dict]): Meta info of each image.
      gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes.
      gt_bboxes_list (list[Tensor]): Gt bboxes of each image.
      label_channels (int): Channel of label.
      sampling (bool): Sample Anchors or not.
      unmap_outputs (bool): unmap outputs or not.
  
  Returns:
      tuple: Returns a tuple containing learning targets.
  
          - labels_list (list[Tensor]): Labels of each level.
          - label_weights_list (list[Tensor]): Label weights of each                     level.
          - bbox_cls_targets_list (list[Tensor]): BBox cls targets of                     each level.
          - bbox_cls_weights_list (list[Tensor]): BBox cls weights of                     each level.
          - bbox_reg_targets_list (list[Tensor]): BBox reg targets of                     each level.
          - bbox_reg_weights_list (list[Tensor]): BBox reg weights of                     each level.
          - num_total_pos (int): Number of positive samples in all                     images.
          - num_total_neg (int): Number of negative samples in all                     images.
docstr_tok: ["Compute","bucketing","targets",".","Args",":","approx_list","(","list","[","list","]",")",":","Multi","level","approxs","of","each","image",".","inside_flag_list","(","list","[","list","]",")",":","Multi","level","inside","flags","of","each","image",".","square_list","(","list","[","list","]",")",":","Multi","level","squares","of","each","image",".","gt_bboxes_list","(","list","[","Tensor","]",")",":","Ground","truth","bboxes","of","each","image",".","img_metas","(","list","[","dict","]",")",":","Meta","info","of","each","image",".","gt_bboxes_ignore_list","(","list","[","Tensor","]",")",":","ignore","list","of","gt","bboxes",".","gt_bboxes_list","(","list","[","Tensor","]",")",":","Gt","bboxes","of","each","image",".","label_channels","(","int",")",":","Channel","of","label",".","sampling","(","bool",")",":","Sample","Anchors","or","not",".","unmap_outputs","(","bool",")",":","unmap","outputs","or","not",".","Returns",":","tuple",":","Returns","a","tuple","containing","learning","targets",".","-","labels_list","(","list","[","Tensor","]",")",":","Labels","of","each","level",".","-","label_weights_list","(","list","[","Tensor","]",")",":","Label","weights","of","each","level",".","-","bbox_cls_targets_list","(","list","[","Tensor","]",")",":","BBox","cls","targets","of","each","level",".","-","bbox_cls_weights_list","(","list","[","Tensor","]",")",":","BBox","cls","weights","of","each","level",".","-","bbox_reg_targets_list","(","list","[","Tensor","]",")",":","BBox","reg","targets","of","each","level",".","-","bbox_reg_weights_list","(","list","[","Tensor","]",")",":","BBox","reg","weights","of","each","level",".","-","num_total_pos","(","int",")",":","Number","of","positive","samples","in","all","images",".","-","num_total_neg","(","int",")",":","Number","of","negative","samples","in","all","images","."]
code: def get_target(
      self,
      approx_list,
      inside_flag_list,
      square_list,
      gt_bboxes_list,
      img_metas,
      gt_bboxes_ignore_list=None,
      gt_labels_list=None,
      label_channels=None,
      sampling=True,
      unmap_outputs=True,
  ):
      """Compute bucketing targets.
          Args:
              approx_list (list[list]): Multi level approxs of each image.
              inside_flag_list (list[list]): Multi level inside flags of each
                  image.
              square_list (list[list]): Multi level squares of each image.
              gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image.
              img_metas (list[dict]): Meta info of each image.
              gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes.
              gt_bboxes_list (list[Tensor]): Gt bboxes of each image.
              label_channels (int): Channel of label.
              sampling (bool): Sample Anchors or not.
              unmap_outputs (bool): unmap outputs or not.
  
          Returns:
              tuple: Returns a tuple containing learning targets.
  
                  - labels_list (list[Tensor]): Labels of each level.
                  - label_weights_list (list[Tensor]): Label weights of each \
                      level.
                  - bbox_cls_targets_list (list[Tensor]): BBox cls targets of \
                      each level.
                  - bbox_cls_weights_list (list[Tensor]): BBox cls weights of \
                      each level.
                  - bbox_reg_targets_list (list[Tensor]): BBox reg targets of \
                      each level.
                  - bbox_reg_weights_list (list[Tensor]): BBox reg weights of \
                      each level.
                  - num_total_pos (int): Number of positive samples in all \
                      images.
                  - num_total_neg (int): Number of negative samples in all \
                      images.
          """
      num_imgs = len(img_metas)
      assert (
          len(approx_list)
          == len(inside_flag_list)
          == len(square_list)
          == num_imgs
      )
      # anchor number of multi levels
      num_level_squares = [
          squares.size(0) for squares in square_list[0]
      ]
      # concat all level anchors and flags to a single tensor
      inside_flag_flat_list = []
      approx_flat_list = []
      square_flat_list = []
      for i in range(num_imgs):
          assert len(square_list[i]) == len(inside_flag_list[i])
          inside_flag_flat_list.append(torch.cat(inside_flag_list[i]))
          approx_flat_list.append(torch.cat(approx_list[i]))
          square_flat_list.append(torch.cat(square_list[i]))
  
      # compute targets for each image
      if gt_bboxes_ignore_list is None:
          gt_bboxes_ignore_list = [None for _ in range(num_imgs)]
      if gt_labels_list is None:
          gt_labels_list = [None for _ in range(num_imgs)]
      (
          all_labels,
          all_label_weights,
          all_bbox_cls_targets,
          all_bbox_cls_weights,
          all_bbox_reg_targets,
          all_bbox_reg_weights,
          pos_inds_list,
          neg_inds_list,
      ) = multi_apply(
          self._get_target_single,
          approx_flat_list,
          inside_flag_flat_list,
          square_flat_list,
          gt_bboxes_list,
          gt_bboxes_ignore_list,
          gt_labels_list,
          img_metas,
          label_channels=label_channels,
          sampling=sampling,
          unmap_outputs=unmap_outputs,
      )
      # no valid anchors
      if any([labels is None for labels in all_labels]):
          return None
      # sampled anchors of all images
      num_total_pos = sum(
          [max(inds.numel(), 1) for inds in pos_inds_list]
      )
      num_total_neg = sum(
          [max(inds.numel(), 1) for inds in neg_inds_list]
      )
      # split targets to a list w.r.t. multiple levels
      labels_list = images_to_levels(all_labels, num_level_squares)
      label_weights_list = images_to_levels(
          all_label_weights, num_level_squares
      )
      bbox_cls_targets_list = images_to_levels(
          all_bbox_cls_targets, num_level_squares
      )
      bbox_cls_weights_list = images_to_levels(
          all_bbox_cls_weights, num_level_squares
      )
      bbox_reg_targets_list = images_to_levels(
          all_bbox_reg_targets, num_level_squares
      )
      bbox_reg_weights_list = images_to_levels(
          all_bbox_reg_weights, num_level_squares
      )
      return (
          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,
      )
  
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 7 for calling the SABLRetinaHead obj's underlying member method code with example usage: obj.get_target(approx_list, inside_flag_list, square_list, gt_bboxes_list, img_metas, gt_bboxes_ignore_list, gt_labels_list, label_channels, sampling, unmap_outputs) and returns: 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, None