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: Forward function.
  
  Args:
      feats (tuple[Tensor]): Features from the upstream network, each is
          a 4D-tensor.
      img_metas (list[dict]): List of image information.
  
  Returns:
      tuple[list[Tensor], list[Tensor]]: Outputs for all scale levels.
  
          - all_cls_scores_list (list[Tensor]): Classification scores                     for each scale level. Each is a 4D-tensor with shape                     [nb_dec, bs, num_query, cls_out_channels]. Note                     `cls_out_channels` should includes background.
          - all_bbox_preds_list (list[Tensor]): Sigmoid regression                     outputs for each scale level. Each is a 4D-tensor with                     normalized coordinate format (cx, cy, w, h) and shape                     [nb_dec, bs, num_query, 4].
docstr_tok: ["Forward","function",".","Args",":","feats","(","tuple","[","Tensor","]",")",":","Features","from","the","upstream","network",",","each","is","a","4D-tensor",".","img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","Returns",":","tuple","[","list","[","Tensor","]",",","list","[","Tensor","]","]",":","Outputs","for","all","scale","levels",".","-","all_cls_scores_list","(","list","[","Tensor","]",")",":","Classification","scores","for","each","scale","level",".","Each","is","a","4D-tensor","with","shape","[","nb_dec",",","bs",",","num_query",",","cls_out_channels","]",".","Note","`","cls_out_channels","`","should","includes","background",".","-","all_bbox_preds_list","(","list","[","Tensor","]",")",":","Sigmoid","regression","outputs","for","each","scale","level",".","Each","is","a","4D-tensor","with","normalized","coordinate","format","(","cx",",","cy",",","w",",","h",")","and","shape","[","nb_dec",",","bs",",","num_query",",","4","]","."]
code: def forward(self, feats, img_metas):
      """Forward function.
  
          Args:
              feats (tuple[Tensor]): Features from the upstream network, each is
                  a 4D-tensor.
              img_metas (list[dict]): List of image information.
  
          Returns:
              tuple[list[Tensor], list[Tensor]]: Outputs for all scale levels.
  
                  - all_cls_scores_list (list[Tensor]): Classification scores \
                      for each scale level. Each is a 4D-tensor with shape \
                      [nb_dec, bs, num_query, cls_out_channels]. Note \
                      `cls_out_channels` should includes background.
                  - all_bbox_preds_list (list[Tensor]): Sigmoid regression \
                      outputs for each scale level. Each is a 4D-tensor with \
                      normalized coordinate format (cx, cy, w, h) and shape \
                      [nb_dec, bs, num_query, 4].
          """
      num_levels = len(feats)
      img_metas_list = [img_metas for _ in range(num_levels)]
      return multi_apply(self.forward_single, feats, img_metas_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 5 for calling the TransformerHead obj's underlying member method code with example usage: obj.forward(feats, img_metas) and returns: multi_apply