class_docstr: Guided-Anchor-based head (GA-RPN, GA-RetinaNet, etc.).
  
  This GuidedAnchorHead will predict high-quality feature guided
  anchors and locations where anchors will be kept in inference.
  There are mainly 3 categories of bounding-boxes.
  
  - Sampled 9 pairs for target assignment. (approxes)
  - The square boxes where the predicted anchors are based on. (squares)
  - Guided anchors.
  
  Please refer to https://arxiv.org/abs/1901.03278 for more details.
  
  Args:
      num_classes (int): Number of classes.
      in_channels (int): Number of channels in the input feature map.
      feat_channels (int): Number of hidden channels.
      approx_anchor_generator (dict): Config dict for approx generator
      square_anchor_generator (dict): Config dict for square generator
      anchor_coder (dict): Config dict for anchor coder
      bbox_coder (dict): Config dict for bbox coder
      deform_groups: (int): Group number of DCN in
          FeatureAdaption module.
      loc_filter_thr (float): Threshold to filter out unconcerned regions.
      loss_loc (dict): Config of location loss.
      loss_shape (dict): Config of anchor shape loss.
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of bbox regression loss.
docstr: Compute guided anchoring 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.
      unmap_outputs (bool): unmap outputs or not.
  
  Returns:
      tuple
docstr_tok: ["Compute","guided","anchoring","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",".","unmap_outputs","(","bool",")",":","unmap","outputs","or","not",".","Returns",":","tuple"]
code: def ga_shape_targets(
      self,
      approx_list,
      inside_flag_list,
      square_list,
      gt_bboxes_list,
      img_metas,
      gt_bboxes_ignore_list=None,
      unmap_outputs=True,
  ):
      """Compute guided anchoring 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.
          unmap_outputs (bool): unmap outputs or not.
  
      Returns:
          tuple
      """
      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)]
      (
          all_bbox_anchors,
          all_bbox_gts,
          all_bbox_weights,
          pos_inds_list,
          neg_inds_list,
      ) = multi_apply(
          self._ga_shape_target_single,
          approx_flat_list,
          inside_flag_flat_list,
          square_flat_list,
          gt_bboxes_list,
          gt_bboxes_ignore_list,
          img_metas,
          unmap_outputs=unmap_outputs,
      )
      # no valid anchors
      if any(
          [bbox_anchors is None for bbox_anchors in all_bbox_anchors]
      ):
          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
      bbox_anchors_list = images_to_levels(
          all_bbox_anchors, num_level_squares
      )
      bbox_gts_list = images_to_levels(all_bbox_gts, num_level_squares)
      bbox_weights_list = images_to_levels(
          all_bbox_weights, num_level_squares
      )
      return (
          bbox_anchors_list,
          bbox_gts_list,
          bbox_weights_list,
          num_total_pos,
          num_total_neg,
      )
  
imports: import torch
  import torch.nn
  from mmcv.cnn import bias_init_with_prob, normal_init
  from mmcv.ops import DeformConv2d, MaskedConv2d
  from mmcv.runner import force_fp32
  from mmdet.core import anchor_inside_flags, build_anchor_generator, build_assigner, build_bbox_coder, build_sampler, calc_region, images_to_levels, multi_apply, multiclass_nms, unmap
  from ..builder import HEADS, build_loss
  from .anchor_head import AnchorHead
label_desc: Use image node_id 11 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj.ga_shape_targets(approx_list, inside_flag_list, square_list, gt_bboxes_list, img_metas, gt_bboxes_ignore_list, unmap_outputs) and returns: bbox_anchors_list,  bbox_gts_list,  bbox_weights_list,  num_total_pos,  num_total_neg, None