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.
  
  This function returns sampled anchors and gt bboxes directly
  rather than calculates regression targets.
  
  Args:
      flat_approxs (Tensor): flat approxs of a single image,
          shape (n, 4)
      inside_flags (Tensor): inside flags of a single image,
          shape (n, ).
      flat_squares (Tensor): flat squares of a single image,
          shape (approxs_per_octave * n, 4)
      gt_bboxes (Tensor): Ground truth bboxes of a single image.
      img_meta (dict): Meta info of a single image.
      approxs_per_octave (int): number of approxs per octave
      cfg (dict): RPN train configs.
      unmap_outputs (bool): unmap outputs or not.
  
  Returns:
      tuple
docstr_tok: ["Compute","guided","anchoring","targets",".","This","function","returns","sampled","anchors","and","gt","bboxes","directly","rather","than","calculates","regression","targets",".","Args",":","flat_approxs","(","Tensor",")",":","flat","approxs","of","a","single","image",",","shape","(","n",",","4",")","inside_flags","(","Tensor",")",":","inside","flags","of","a","single","image",",","shape","(","n",",",")",".","flat_squares","(","Tensor",")",":","flat","squares","of","a","single","image",",","shape","(","approxs_per_octave","*","n",",","4",")","gt_bboxes","(","Tensor",")",":","Ground","truth","bboxes","of","a","single","image",".","img_meta","(","dict",")",":","Meta","info","of","a","single","image",".","approxs_per_octave","(","int",")",":","number","of","approxs","per","octave","cfg","(","dict",")",":","RPN","train","configs",".","unmap_outputs","(","bool",")",":","unmap","outputs","or","not",".","Returns",":","tuple"]
code: def _ga_shape_target_single(
      self,
      flat_approxs,
      inside_flags,
      flat_squares,
      gt_bboxes,
      gt_bboxes_ignore,
      img_meta,
      unmap_outputs=True,
  ):
      """Compute guided anchoring targets.
  
      This function returns sampled anchors and gt bboxes directly
      rather than calculates regression targets.
  
      Args:
          flat_approxs (Tensor): flat approxs of a single image,
              shape (n, 4)
          inside_flags (Tensor): inside flags of a single image,
              shape (n, ).
          flat_squares (Tensor): flat squares of a single image,
              shape (approxs_per_octave * n, 4)
          gt_bboxes (Tensor): Ground truth bboxes of a single image.
          img_meta (dict): Meta info of a single image.
          approxs_per_octave (int): number of approxs per octave
          cfg (dict): RPN train configs.
          unmap_outputs (bool): unmap outputs or not.
  
      Returns:
          tuple
      """
      if not inside_flags.any():
          return (None,) * 5
      # assign gt and sample anchors
      expand_inside_flags = (
          inside_flags[:, None]
          .expand(-1, self.approxs_per_octave)
          .reshape(-1)
      )
      approxs = flat_approxs[expand_inside_flags, :]
      squares = flat_squares[inside_flags, :]
  
      assign_result = self.ga_assigner.assign(
          approxs,
          squares,
          self.approxs_per_octave,
          gt_bboxes,
          gt_bboxes_ignore,
      )
      sampling_result = self.ga_sampler.sample(
          assign_result, squares, gt_bboxes
      )
  
      bbox_anchors = torch.zeros_like(squares)
      bbox_gts = torch.zeros_like(squares)
      bbox_weights = torch.zeros_like(squares)
  
      pos_inds = sampling_result.pos_inds
      neg_inds = sampling_result.neg_inds
      if len(pos_inds) > 0:
          bbox_anchors[pos_inds, :] = sampling_result.pos_bboxes
          bbox_gts[pos_inds, :] = sampling_result.pos_gt_bboxes
          bbox_weights[pos_inds, :] = 1.0
  
      # map up to original set of anchors
      if unmap_outputs:
          num_total_anchors = flat_squares.size(0)
          bbox_anchors = unmap(
              bbox_anchors, num_total_anchors, inside_flags
          )
          bbox_gts = unmap(bbox_gts, num_total_anchors, inside_flags)
          bbox_weights = unmap(
              bbox_weights, num_total_anchors, inside_flags
          )
  
      return (bbox_anchors, bbox_gts, bbox_weights, pos_inds, neg_inds)
  
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 10 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj._ga_shape_target_single(flat_approxs, inside_flags, flat_squares, gt_bboxes, gt_bboxes_ignore, img_meta, unmap_outputs) and returns: bbox_anchors,  bbox_gts,  bbox_weights,  pos_inds,  neg_inds, unknown