class_docstr: Head of DETR. DETR:End-to-End Object Detection with Transformers.
  
  More details can be found in the `paper
  <https://arxiv.org/pdf/2005.12872>`_ .
  
  Args:
      num_classes (int): Number of categories excluding the background.
      embed_dims (int): The dims of Transformer embedding.
      num_reg_fcs (int): Number of fully-connected layers used in `FFN`,
          which is then used for the regression head. Defaults to 2.
      sync_cls_avg_factor (bool): Whether to sync the `avg_factor` of
          all ranks. Default to `False`.
      loss_cls (:obj:`ConfigDict` or dict): Config of the classification
          loss. Defaults to `CrossEntropyLoss`.
      loss_bbox (:obj:`ConfigDict` or dict): Config of the regression bbox
          loss. Defaults to `L1Loss`.
      loss_iou (:obj:`ConfigDict` or dict): Config of the regression iou
          loss. Defaults to `GIoULoss`.
      train_cfg (:obj:`ConfigDict` or dict): Training config of transformer
          head.
      test_cfg (:obj:`ConfigDict` or dict): Testing config of transformer
          head.
      init_cfg (:obj:`ConfigDict` or dict, optional): the config to control
          the initialization. Defaults to None.
docstr: Transform network outputs for a batch into bbox predictions.
  
  Args:
      layer_cls_scores (Tensor): Classification outputs of the last or
          all decoder layer. Each is a 4D-tensor, has shape
          (num_decoder_layers, bs, num_queries, cls_out_channels).
      layer_bbox_preds (Tensor): Sigmoid regression outputs of the last
          or all decoder layer. Each is a 4D-tensor with normalized
          coordinate format (cx, cy, w, h) and shape
          (num_decoder_layers, bs, num_queries, 4).
      batch_img_metas (list[dict]): Meta information of each image.
      rescale (bool, optional): If `True`, return boxes in original
          image space. 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","network","outputs","for","a","batch","into","bbox","predictions",".","Args",":","layer_cls_scores","(","Tensor",")",":","Classification","outputs","of","the","last","or","all","decoder","layer",".","Each","is","a","4D-tensor",",","has","shape","(","num_decoder_layers",",","bs",",","num_queries",",","cls_out_channels",")",".","layer_bbox_preds","(","Tensor",")",":","Sigmoid","regression","outputs","of","the","last","or","all","decoder","layer",".","Each","is","a","4D-tensor","with","normalized","coordinate","format","(","cx",",","cy",",","w",",","h",")","and","shape","(","num_decoder_layers",",","bs",",","num_queries",",","4",")",".","batch_img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",".","rescale","(","bool",",","optional",")",":","If","`","True","`",",","return","boxes","in","original","image","space",".","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,
      layer_cls_scores: Tensor,
      layer_bbox_preds: Tensor,
      batch_img_metas: List[dict],
      rescale: bool = True,
  ) -> InstanceList:
      """Transform network outputs for a batch into bbox predictions.
  
      Args:
          layer_cls_scores (Tensor): Classification outputs of the last or
              all decoder layer. Each is a 4D-tensor, has shape
              (num_decoder_layers, bs, num_queries, cls_out_channels).
          layer_bbox_preds (Tensor): Sigmoid regression outputs of the last
              or all decoder layer. Each is a 4D-tensor with normalized
              coordinate format (cx, cy, w, h) and shape
              (num_decoder_layers, bs, num_queries, 4).
          batch_img_metas (list[dict]): Meta information of each image.
          rescale (bool, optional): If `True`, return boxes in original
              image space. 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).
      """
      # NOTE only using outputs from the last feature level,
      # and only the outputs from the last decoder layer is used.
      cls_scores = layer_cls_scores[-1]
      bbox_preds = layer_bbox_preds[-1]
  
      result_list = []
      for img_id in range(len(batch_img_metas)):
          cls_score = cls_scores[img_id]
          bbox_pred = bbox_preds[img_id]
          img_meta = batch_img_metas[img_id]
          results = self._predict_by_feat_single(
              cls_score, bbox_pred, img_meta, rescale
          )
          result_list.append(results)
      return result_list
  
imports: from typing import Dict, List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Linear
  from mmcv.cnn.bricks.transformer import FFN
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_overlaps, bbox_xyxy_to_cxcywh
  from mmdet.utils import ConfigType, InstanceList, OptInstanceList, OptMultiConfig, reduce_mean
  from ..losses import QualityFocalLoss
  from ..utils import multi_apply
label_desc: Use image node_id 11 for calling the DETRHead obj's underlying member method code with example usage: obj.predict_by_feat(layer_cls_scores, layer_bbox_preds, batch_img_metas, rescale) and returns: result_list