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.
code: def _get_bboxes_single(
      self,
      cls_scores,
      bbox_preds,
      mlvl_anchors,
      mlvl_masks,
      img_shape,
      scale_factor,
      cfg,
      rescale=False,
  ):
      cfg = self.test_cfg if cfg is None else cfg
      assert len(cls_scores) == len(bbox_preds) == len(mlvl_anchors)
      mlvl_bboxes = []
      mlvl_scores = []
      for cls_score, bbox_pred, anchors, mask in zip(
          cls_scores, bbox_preds, mlvl_anchors, mlvl_masks
      ):
          assert cls_score.size()[-2:] == bbox_pred.size()[-2:]
          # if no location is kept, end.
          if mask.sum() == 0:
              continue
          # reshape scores and bbox_pred
          cls_score = cls_score.permute(1, 2, 0).reshape(
              -1, self.cls_out_channels
          )
          if self.use_sigmoid_cls:
              scores = cls_score.sigmoid()
          else:
              scores = cls_score.softmax(-1)
          bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4)
          # filter scores, bbox_pred w.r.t. mask.
          # anchors are filtered in get_anchors() beforehand.
          scores = scores[mask, :]
          bbox_pred = bbox_pred[mask, :]
          if scores.dim() == 0:
              anchors = anchors.unsqueeze(0)
              scores = scores.unsqueeze(0)
              bbox_pred = bbox_pred.unsqueeze(0)
          # filter anchors, bbox_pred, scores w.r.t. scores
          nms_pre = cfg.get("nms_pre", -1)
          if nms_pre > 0 and scores.shape[0] > nms_pre:
              if self.use_sigmoid_cls:
                  max_scores, _ = scores.max(dim=1)
              else:
                  # remind that we set FG labels to [0, num_class-1]
                  # since mmdet v2.0
                  # BG cat_id: num_class
                  max_scores, _ = scores[:, :-1].max(dim=1)
              _, topk_inds = max_scores.topk(nms_pre)
              anchors = anchors[topk_inds, :]
              bbox_pred = bbox_pred[topk_inds, :]
              scores = scores[topk_inds, :]
          bboxes = self.bbox_coder.decode(
              anchors, bbox_pred, max_shape=img_shape
          )
          mlvl_bboxes.append(bboxes)
          mlvl_scores.append(scores)
      mlvl_bboxes = torch.cat(mlvl_bboxes)
      if rescale:
          mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor)
      mlvl_scores = torch.cat(mlvl_scores)
      if self.use_sigmoid_cls:
          # Add a dummy background class to the backend when using sigmoid
          # remind that we set FG labels to [0, num_class-1] since mmdet v2.0
          # BG cat_id: num_class
          padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1)
          mlvl_scores = torch.cat([mlvl_scores, padding], dim=1)
      # multi class NMS
      det_bboxes, det_labels = multiclass_nms(
          mlvl_bboxes,
          mlvl_scores,
          cfg.score_thr,
          cfg.nms,
          cfg.max_per_img,
      )
      return det_bboxes, det_labels
  
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 16 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj._get_bboxes_single(cls_scores, bbox_preds, mlvl_anchors, mlvl_masks, img_shape, scale_factor, cfg, rescale) and returns: det_bboxes,  det_labels