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: Initialize layers of the transformer head.
docstr_tok: ["Initialize","layers","of","the","transformer","head","."]
code: def _init_layers(self):
      """Initialize layers of the transformer head."""
      self.input_proj = Conv2d(
          self.in_channels, self.embed_dims, kernel_size=1
      )
      self.fc_cls = Linear(self.embed_dims, self.cls_out_channels)
      self.reg_ffn = FFN(
          self.embed_dims,
          self.embed_dims,
          self.num_fcs,
          self.act_cfg,
          dropout=0.0,
          add_residual=False,
      )
      self.fc_reg = Linear(self.embed_dims, 4)
      self.query_embedding = nn.Embedding(
          self.num_query, self.embed_dims
      )
  
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 2 for calling the TransformerHead obj's underlying member method code with example usage: obj._init_layers() without return types