class_docstr: Implements the DETR transformer head.
  
  See `paper: End-to-End Object Detection with Transformers
  <https://arxiv.org/pdf/2005.12872>`_ for details.
  
  Args:
      num_classes (int): Number of categories excluding the background.
      in_channels (int): Number of channels in the input feature map.
      num_fcs (int, optional): Number of fully-connected layers used in
          `FFN`, which is then used for the regression head. Default 2.
      transformer (dict, optional): Config for transformer.
      positional_encoding (dict, optional): Config for position encoding.
      loss_cls (dict, optional): Config of the classification loss.
          Default `CrossEntropyLoss`.
      loss_bbox (dict, optional): Config of the regression loss.
          Default `L1Loss`.
      loss_iou (dict, optional): Config of the regression iou loss.
          Default `GIoULoss`.
      tran_cfg (dict, optional): Training config of transformer head.
      test_cfg (dict, optional): Testing config of transformer head.
  
  Example:
      >>> import torch
      >>> self = TransformerHead(80, 2048)
      >>> x = torch.rand(1, 2048, 32, 32)
      >>> mask = torch.ones(1, 32, 32).to(x.dtype)
      >>> mask[:, :16, :15] = 0
      >>> all_cls_scores, all_bbox_preds = self(x, mask)
docstr: Transform network outputs for a batch into bbox predictions.
  
  Args:
      all_cls_scores_list (list[Tensor]): Classification outputs
          for each feature level. Each is a 4D-tensor with shape
          [nb_dec, bs, num_query, cls_out_channels].
      all_bbox_preds_list (list[Tensor]): Sigmoid regression
          outputs for each feature level. Each is a 4D-tensor with
          normalized coordinate format (cx, cy, w, h) and shape
          [nb_dec, bs, num_query, 4].
      img_metas (list[dict]): Meta information of each image.
      rescale (bool, optional): If True, return boxes in original
          image space. Defalut False.
  
  Returns:
      list[list[Tensor, Tensor]]: Each item in result_list is 2-tuple.                 The first item is an (n, 5) tensor, where the first 4 columns                 are bounding box positions (tl_x, tl_y, br_x, br_y) and the                 5-th column is a score between 0 and 1. The second item is a                 (n,) tensor where each item is the predicted class label of                 the corresponding box.
docstr_tok: ["Transform","network","outputs","for","a","batch","into","bbox","predictions",".","Args",":","all_cls_scores_list","(","list","[","Tensor","]",")",":","Classification","outputs","for","each","feature","level",".","Each","is","a","4D-tensor","with","shape","[","nb_dec",",","bs",",","num_query",",","cls_out_channels","]",".","all_bbox_preds_list","(","list","[","Tensor","]",")",":","Sigmoid","regression","outputs","for","each","feature","level",".","Each","is","a","4D-tensor","with","normalized","coordinate","format","(","cx",",","cy",",","w",",","h",")","and","shape","[","nb_dec",",","bs",",","num_query",",","4","]",".","img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",".","rescale","(","bool",",","optional",")",":","If","True",",","return","boxes","in","original","image","space",".","Defalut","False",".","Returns",":","list","[","list","[","Tensor",",","Tensor","]","]",":","Each","item","in","result_list","is","2-tuple",".","The","first","item","is","an","(","n",",","5",")","tensor",",","where","the","first","4","columns","are","bounding","box","positions","(","tl_x",",","tl_y",",","br_x",",","br_y",")","and","the","5-th","column","is","a","score","between","0","and","1",".","The","second","item","is","a","(","n",",",")","tensor","where","each","item","is","the","predicted","class","label","of","the","corresponding","box","."]
code: def get_bboxes(
      self,
      all_cls_scores_list,
      all_bbox_preds_list,
      img_metas,
      rescale=False,
  ):
      """Transform network outputs for a batch into bbox predictions.
  
          Args:
              all_cls_scores_list (list[Tensor]): Classification outputs
                  for each feature level. Each is a 4D-tensor with shape
                  [nb_dec, bs, num_query, cls_out_channels].
              all_bbox_preds_list (list[Tensor]): Sigmoid regression
                  outputs for each feature level. Each is a 4D-tensor with
                  normalized coordinate format (cx, cy, w, h) and shape
                  [nb_dec, bs, num_query, 4].
              img_metas (list[dict]): Meta information of each image.
              rescale (bool, optional): If True, return boxes in original
                  image space. Defalut False.
  
          Returns:
              list[list[Tensor, Tensor]]: Each item in result_list is 2-tuple. \
                  The first item is an (n, 5) tensor, where the first 4 columns \
                  are bounding box positions (tl_x, tl_y, br_x, br_y) and the \
                  5-th column is a score between 0 and 1. The second item is a \
                  (n,) tensor where each item is the predicted class label of \
                  the corresponding box.
          """
      # NOTE defaultly only using outputs from the last feature level,
      # and only the ouputs from the last decoder layer is used.
      cls_scores = all_cls_scores_list[-1][-1]
      bbox_preds = all_bbox_preds_list[-1][-1]
  
      result_list = []
      for img_id in range(len(img_metas)):
          cls_score = cls_scores[img_id]
          bbox_pred = bbox_preds[img_id]
          img_shape = img_metas[img_id]["img_shape"]
          scale_factor = img_metas[img_id]["scale_factor"]
          proposals = self._get_bboxes_single(
              cls_score, bbox_pred, img_shape, scale_factor, rescale
          )
          result_list.append(proposals)
      return result_list
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, Linear, build_activation_layer
  from mmcv.runner import force_fp32
  from mmdet.core import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh, build_assigner, build_sampler, multi_apply, reduce_mean
  from mmdet.models.utils import FFN, build_positional_encoding, build_transformer
  from ..builder import HEADS, build_loss
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 12 for calling the TransformerHead obj's underlying member method code with example usage: obj.get_bboxes(all_cls_scores_list, all_bbox_preds_list, img_metas, rescale) and returns: result_list