class_docstr: This class defines the pre-norm `Transformer encoder <https://arxiv.org/abs/1706.03762>`_
  Args:
      opts: Command line arguments.
      embed_dim: :math:`C_{in}` from an expected input of size :math:`(N, P, C_{in})`.
      ffn_latent_dim: Inner dimension of the FFN.
      num_heads: Number of heads in multi-head attention. Default: 8.
      attn_dropout: Dropout rate for attention in multi-head attention. Default: 0.0
      dropout: Dropout rate. Default: 0.0.
      ffn_dropout: Dropout between FFN layers. Default: 0.0.
      transformer_norm_layer: Normalization layer. Default: layer_norm.
      stochastic_dropout: Stochastic dropout setting. Default: 0.0.
  
  Shape:
      - Input: :math:`(N, P, C_{in})` where :math:`N` is batch size, :math:`P` is number of patches,
      and :math:`C_{in}` is input embedding dim
      - Output: same shape as the input
class_docstr_tok: ["This","class","defines","the","pre-norm","`","Transformer","encoder","<","https",":","\/\/arxiv.org\/abs\/1706.03762",">","`","_","Args",":","opts",":","Command","line","arguments",".","embed_dim",":",":","math",":","`","C_","{","in","}","`","from","an","expected","input","of","size",":","math",":","`","(","N",",","P",",","C_","{","in","}",")","`",".","ffn_latent_dim",":","Inner","dimension","of","the","FFN",".","num_heads",":","Number","of","heads","in","multi-head","attention",".","Default",":","8.","attn_dropout",":","Dropout","rate","for","attention","in","multi-head","attention",".","Default",":","0.0","dropout",":","Dropout","rate",".","Default",":","0.0.","ffn_dropout",":","Dropout","between","FFN","layers",".","Default",":","0.0.","transformer_norm_layer",":","Normalization","layer",".","Default",":","layer_norm",".","stochastic_dropout",":","Stochastic","dropout","setting",".","Default",":","0.0",".","Shape",":","-","Input",":",":","math",":","`","(","N",",","P",",","C_","{","in","}",")","`","where",":","math",":","`","N","`","is","batch","size",",",":","math",":","`","P","`","is","number","of","patches",",","and",":","math",":","`","C_","{","in","}","`","is","input","embedding","dim","-","Output",":","same","shape","as","the","input"]
code: def __repr__(self) -> str:
      return "{}(embed_dim={}, ffn_dim={}, dropout={}, ffn_dropout={}, stochastic_dropout={}, attn_fn={}, act_fn={}, norm_fn={})".format(
          self.__class__.__name__,
          self.embed_dim,
          self.ffn_dim,
          self.std_dropout,
          self.ffn_dropout,
          self.stochastic_dropout,
          self.attn_fn_name,
          self.act_fn_name,
          self.norm_type,
      )
  
file_path: ml-cvnets/cvnets/modules/transformer.py
imports: import argparse
  from typing import Optional
  from torch import Tensor, nn
  from cvnets.layers import ConvLayer2d, Dropout, Identity, LinearLayer, LinearSelfAttention, MultiHeadAttention, SingleHeadAttention, StochasticDepth, get_normalization_layer
  from cvnets.layers.activation import build_activation_layer
  from cvnets.modules import BaseModule
  from utils import logger
label_desc: Use image node_id 2 for calling the TransformerEncoder obj's underlying member method code with example usage: obj.__repr__() and returns: str