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. Defaults to 256.
      approx_anchor_generator (:obj:`ConfigDict` or dict): Config dict
          for approx generator
      square_anchor_generator (:obj:`ConfigDict` or dict): Config dict
          for square generator
      anchor_coder (:obj:`ConfigDict` or dict): Config dict for anchor coder
      bbox_coder (:obj:`ConfigDict` or dict): Config dict for bbox coder
      reg_decoded_bbox (bool): If true, the regression loss would be
          applied directly on decoded bounding boxes, converting both
          the predicted boxes and regression targets to absolute
          coordinates format. Defaults to False. It should be `True` when
          using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head.
      deform_groups: (int): Group number of DCN in FeatureAdaption module.
          Defaults to 4.
      loc_filter_thr (float): Threshold to filter out unconcerned regions.
          Defaults to 0.01.
      loss_loc (:obj:`ConfigDict` or dict): Config of location loss.
      loss_shape (:obj:`ConfigDict` or dict): Config of anchor shape loss.
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox (:obj:`ConfigDict` or dict): Config of bbox regression loss.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or             list[dict], optional): Initialization config dict.
class_docstr_tok: ["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",".","Defaults","to","256.","approx_anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","approx","generator","square_anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","square","generator","anchor_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","anchor","coder","bbox_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","bbox","coder","reg_decoded_bbox","(","bool",")",":","If","true",",","the","regression","loss","would","be","applied","directly","on","decoded","bounding","boxes",",","converting","both","the","predicted","boxes","and","regression","targets","to","absolute","coordinates","format",".","Defaults","to","False",".","It","should","be","`","True","`","when","using","`","IoULoss","`",",","`","GIoULoss","`",",","or","`","DIoULoss","`","in","the","bbox","head",".","deform_groups",":","(","int",")",":","Group","number","of","DCN","in","FeatureAdaption","module",".","Defaults","to","4.","loc_filter_thr","(","float",")",":","Threshold","to","filter","out","unconcerned","regions",".","Defaults","to","0.01.","loss_loc","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","location","loss",".","loss_shape","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","anchor","shape","loss",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","bbox","regression","loss",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","list","[",":","obj",":","`","ConfigDict","`","]","or","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict","."]
docstr: Transform a batch of output features extracted from the head into
  bbox results.
  
  Args:
      cls_scores (list[Tensor]): Classification scores for all
          scale levels, each is a 4D-tensor, has shape
          (batch_size, num_priors * num_classes, H, W).
      bbox_preds (list[Tensor]): Box energies / deltas for all
          scale levels, each is a 4D-tensor, has shape
          (batch_size, num_priors * 4, H, W).
      shape_preds (list[Tensor]): shape predictions for each scale
          level with shape (N, 1, H, W).
      loc_preds (list[Tensor]): location predictions for each scale
          level with shape (N, num_anchors * 2, H, W).
      batch_img_metas (list[dict], Optional): Batch image meta info.
          Defaults to None.
      cfg (ConfigDict, optional): Test / postprocessing
          configuration, if None, test_cfg would be used.
          Defaults to None.
      rescale (bool): If True, return boxes in original image space.
          Defaults to False.
  
  Returns:
      list[:obj:`InstanceData`]: Object detection results of each image
      after the post process. Each item usually contains following keys.
  
      - scores (Tensor): Classification scores, has a shape
        (num_instance, )
      - labels (Tensor): Labels of bboxes, has a shape (num_instances, ).
      - bboxes (Tensor): Has a shape (num_instances, 4), the last
        dimension 4 arrange as (x1, y1, x2, y2).
docstr_tok: ["Transform","a","batch","of","output","features","extracted","from","the","head","into","bbox","results",".","Args",":","cls_scores","(","list","[","Tensor","]",")",":","Classification","scores","for","all","scale","levels",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","num_classes",",","H",",","W",")",".","bbox_preds","(","list","[","Tensor","]",")",":","Box","energies","\/","deltas","for","all","scale","levels",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","4",",","H",",","W",")",".","shape_preds","(","list","[","Tensor","]",")",":","shape","predictions","for","each","scale","level","with","shape","(","N",",","1",",","H",",","W",")",".","loc_preds","(","list","[","Tensor","]",")",":","location","predictions","for","each","scale","level","with","shape","(","N",",","num_anchors","*","2",",","H",",","W",")",".","batch_img_metas","(","list","[","dict","]",",","Optional",")",":","Batch","image","meta","info",".","Defaults","to","None",".","cfg","(","ConfigDict",",","optional",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","Defaults","to","None",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Defaults","to","False",".","Returns",":","list","[",":","obj",":","`","InstanceData","`","]",":","Object","detection","results","of","each","image","after","the","post","process",".","Each","item","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")","."]
code: def predict_by_feat(
      self,
      cls_scores: List[Tensor],
      bbox_preds: List[Tensor],
      shape_preds: List[Tensor],
      loc_preds: List[Tensor],
      batch_img_metas: List[dict],
      cfg: OptConfigType = None,
      rescale: bool = False,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      bbox results.
  
      Args:
          cls_scores (list[Tensor]): Classification scores for all
              scale levels, each is a 4D-tensor, has shape
              (batch_size, num_priors * num_classes, H, W).
          bbox_preds (list[Tensor]): Box energies / deltas for all
              scale levels, each is a 4D-tensor, has shape
              (batch_size, num_priors * 4, H, W).
          shape_preds (list[Tensor]): shape predictions for each scale
              level with shape (N, 1, H, W).
          loc_preds (list[Tensor]): location predictions for each scale
              level with shape (N, num_anchors * 2, H, W).
          batch_img_metas (list[dict], Optional): Batch image meta info.
              Defaults to None.
          cfg (ConfigDict, optional): Test / postprocessing
              configuration, if None, test_cfg would be used.
              Defaults to None.
          rescale (bool): If True, return boxes in original image space.
              Defaults to False.
  
      Returns:
          list[:obj:`InstanceData`]: Object detection results of each image
          after the post process. Each item usually contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
            (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4), the last
            dimension 4 arrange as (x1, y1, x2, y2).
      """
      assert (
          len(cls_scores)
          == len(bbox_preds)
          == len(shape_preds)
          == len(loc_preds)
      )
      num_levels = len(cls_scores)
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
      device = cls_scores[0].device
      # get guided anchors
      _, guided_anchors, loc_masks = self.get_anchors(
          featmap_sizes,
          shape_preds,
          loc_preds,
          batch_img_metas,
          use_loc_filter=not self.training,
          device=device,
      )
      result_list = []
      for img_id in range(len(batch_img_metas)):
          cls_score_list = [
              cls_scores[i][img_id].detach() for i in range(num_levels)
          ]
          bbox_pred_list = [
              bbox_preds[i][img_id].detach() for i in range(num_levels)
          ]
          guided_anchor_list = [
              guided_anchors[img_id][i].detach()
              for i in range(num_levels)
          ]
          loc_mask_list = [
              loc_masks[img_id][i].detach() for i in range(num_levels)
          ]
          proposals = self._predict_by_feat_single(
              cls_scores=cls_score_list,
              bbox_preds=bbox_pred_list,
              mlvl_anchors=guided_anchor_list,
              mlvl_masks=loc_mask_list,
              img_meta=batch_img_metas[img_id],
              cfg=cfg,
              rescale=rescale,
          )
          result_list.append(proposals)
      return result_list
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.ops import DeformConv2d, MaskedConv2d
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType, OptInstanceList
  from ..layers import multiclass_nms
  from ..task_modules.prior_generators import anchor_inside_flags, calc_region
  from ..task_modules.samplers import PseudoSampler
  from ..utils import images_to_levels, multi_apply, unmap
  from .anchor_head import AnchorHead
label_desc: Use image node_id 14 for calling the GuidedAnchorHead obj's underlying member method code with example usage: obj.predict_by_feat(cls_scores, bbox_preds, shape_preds, loc_preds, batch_img_metas, cfg, rescale) and returns: result_list