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: Get guided anchors and loc masks for a single level.
  
  Args:
      square (tensor): Squares of a single level.
      shape_pred (tensor): Shape predections of a single level.
      loc_pred (tensor): Loc predections of a single level.
      use_loc_filter (list[tensor]): Use loc filter or not.
  
  Returns:
      tuple: guided anchors, location masks
docstr_tok: ["Get","guided","anchors","and","loc","masks","for","a","single","level",".","Args",":","square","(","tensor",")",":","Squares","of","a","single","level",".","shape_pred","(","tensor",")",":","Shape","predections","of","a","single","level",".","loc_pred","(","tensor",")",":","Loc","predections","of","a","single","level",".","use_loc_filter","(","list","[","tensor","]",")",":","Use","loc","filter","or","not",".","Returns",":","tuple",":","guided","anchors",",","location","masks"]
code: def _get_guided_anchors_single(
      self, squares, shape_pred, loc_pred, use_loc_filter=False
  ):
      """Get guided anchors and loc masks for a single level.
  
      Args:
          square (tensor): Squares of a single level.
          shape_pred (tensor): Shape predections of a single level.
          loc_pred (tensor): Loc predections of a single level.
          use_loc_filter (list[tensor]): Use loc filter or not.
  
      Returns:
          tuple: guided anchors, location masks
      """
      # calculate location filtering mask
      loc_pred = loc_pred.sigmoid().detach()
      if use_loc_filter:
          loc_mask = loc_pred >= self.loc_filter_thr
      else:
          loc_mask = loc_pred >= 0.0
      mask = loc_mask.permute(1, 2, 0).expand(-1, -1, self.num_anchors)
      mask = mask.contiguous().view(-1)
      # calculate guided anchors
      squares = squares[mask]
      anchor_deltas = (
          shape_pred.permute(1, 2, 0)
          .contiguous()
          .view(-1, 2)
          .detach()[mask]
      )
      bbox_deltas = anchor_deltas.new_full(squares.size(), 0)
      bbox_deltas[:, 2:] = anchor_deltas
      guided_anchors = self.anchor_coder.decode(
          squares, bbox_deltas, wh_ratio_clip=1e-6
      )
      return guided_anchors, mask
  
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 8 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj._get_guided_anchors_single(squares, shape_pred, loc_pred, use_loc_filter) and returns: guided_anchors,  mask