class_docstr: Side-Aware Boundary Localization (SABL) for RetinaNet.
  
  The anchor generation, assigning and sampling in SABLRetinaHead
  are the same as GuidedAnchorHead for guided anchoring.
  
  Please refer to https://arxiv.org/abs/1912.04260 for more details.
  
  Args:
      num_classes (int): Number of classes.
      in_channels (int): Number of channels in the input feature map.
      stacked_convs (int): Number of Convs for classification and
          regression branches. Defaults to 4.
      feat_channels (int): Number of hidden channels. Defaults to 256.
      approx_anchor_generator (:obj:`ConfigType` or dict): Config dict for
          approx generator.
      square_anchor_generator (:obj:`ConfigDict` or dict): Config dict for
          square generator.
      conv_cfg (:obj:`ConfigDict` or dict, optional): Config dict for
          ConvModule. Defaults to None.
      norm_cfg (:obj:`ConfigDict` or dict, optional): Config dict for
          Norm Layer. Defaults to None.
      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. Default False. It should be ``True`` when
          using ``IoULoss``, ``GIoULoss``, or ``DIoULoss`` in the bbox head.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config of
          SABLRetinaHead.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          SABLRetinaHead.
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_bbox_cls (:obj:`ConfigDict` or dict): Config of classification
          loss for bbox branch.
      loss_bbox_reg (:obj:`ConfigDict` or dict): Config of regression loss
          for bbox branch.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict.
class_docstr_tok: ["Side-Aware","Boundary","Localization","(","SABL",")","for","RetinaNet",".","The","anchor","generation",",","assigning","and","sampling","in","SABLRetinaHead","are","the","same","as","GuidedAnchorHead","for","guided","anchoring",".","Please","refer","to","https",":","\/\/arxiv.org\/abs\/1912.04260","for","more","details",".","Args",":","num_classes","(","int",")",":","Number","of","classes",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","stacked_convs","(","int",")",":","Number","of","Convs","for","classification","and","regression","branches",".","Defaults","to","4.","feat_channels","(","int",")",":","Number","of","hidden","channels",".","Defaults","to","256.","approx_anchor_generator","(",":","obj",":","`","ConfigType","`","or","dict",")",":","Config","dict","for","approx","generator",".","square_anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","square","generator",".","conv_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","dict","for","ConvModule",".","Defaults","to","None",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","dict","for","Norm","Layer",".","Defaults","to","None",".","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",".","Default","False",".","It","should","be","``","True","``","when","using","``","IoULoss","``",",","``","GIoULoss","``",",","or","``","DIoULoss","``","in","the","bbox","head",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config","of","SABLRetinaHead",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","SABLRetinaHead",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss",".","loss_bbox_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","classification","loss","for","bbox","branch",".","loss_bbox_reg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","regression","loss","for","bbox","branch",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict","."]
docstr: Transform a batch of output features extracted from the head into
  bbox results.
  
  Note: When score_factors is not None, the cls_scores are
  usually multiplied by it then obtain the real score used in NMS,
  such as CenterNess in FCOS, IoU branch in ATSS.
  
  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).
      batch_img_metas (list[dict], Optional): Batch image meta info.
      cfg (:obj:`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.
      with_nms (bool): If True, do nms before return boxes.
          Defaults to True.
  
  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",".","Note",":","When","score_factors","is","not","None",",","the","cls_scores","are","usually","multiplied","by","it","then","obtain","the","real","score","used","in","NMS",",","such","as","CenterNess","in","FCOS",",","IoU","branch","in","ATSS",".","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",")",".","batch_img_metas","(","list","[","dict","]",",","Optional",")",":","Batch","image","meta","info",".","cfg","(",":","obj",":","`","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",".","with_nms","(","bool",")",":","If","True",",","do","nms","before","return","boxes",".","Defaults","to","True",".","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],
      batch_img_metas: List[dict],
      cfg: Optional[ConfigDict] = None,
      rescale: bool = False,
      with_nms: bool = True,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      bbox results.
  
      Note: When score_factors is not None, the cls_scores are
      usually multiplied by it then obtain the real score used in NMS,
      such as CenterNess in FCOS, IoU branch in ATSS.
  
      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).
          batch_img_metas (list[dict], Optional): Batch image meta info.
          cfg (:obj:`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.
          with_nms (bool): If True, do nms before return boxes.
              Defaults to True.
  
      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)
      num_levels = len(cls_scores)
      featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
  
      device = cls_scores[0].device
      mlvl_anchors = self.get_anchors(
          featmap_sizes, batch_img_metas, 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_cls_pred_list = [
              bbox_preds[i][0][img_id].detach()
              for i in range(num_levels)
          ]
          bbox_reg_pred_list = [
              bbox_preds[i][1][img_id].detach()
              for i in range(num_levels)
          ]
          proposals = self._predict_by_feat_single(
              cls_scores=cls_score_list,
              bbox_cls_preds=bbox_cls_pred_list,
              bbox_reg_preds=bbox_reg_pred_list,
              mlvl_anchors=mlvl_anchors[img_id],
              img_meta=batch_img_metas[img_id],
              cfg=cfg,
              rescale=rescale,
              with_nms=with_nms,
          )
          result_list.append(proposals)
      return result_list
  
imports: from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmengine.config import ConfigDict
  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 ..task_modules.samplers import PseudoSampler
  from ..utils import filter_scores_and_topk, images_to_levels, multi_apply, unmap
  from .base_dense_head import BaseDenseHead
  from .guided_anchor_head import GuidedAnchorHead
label_desc: Use image node_id 10 for calling the SABLRetinaHead obj's underlying member method code with example usage: obj.predict_by_feat(cls_scores, bbox_preds, batch_img_metas, cfg, rescale, with_nms) and returns: result_list