class_docstr: Implements one encoder layer in DETR transformer.
  
  Args:
      embed_dims (int): The feature dimension. Same as `FFN`.
      num_heads (int): Parallel attention heads.
      feedforward_channels (int): The hidden dimension for FFNs.
      dropout (float): Probability of an element to be zeroed. Default 0.0.
      order (tuple[str]): The order for encoder layer. Valid examples are
          ('selfattn', 'norm', 'ffn', 'norm') and ('norm', 'selfattn',
          'norm', 'ffn'). Default ('selfattn', 'norm', 'ffn', 'norm').
      act_cfg (dict): The activation config for FFNs. Defalut ReLU.
      norm_cfg (dict): Config dict for normalization layer. Default
          layer normalization.
      num_fcs (int): The number of fully-connected layers for FFNs.
          Default 2.
class_docstr_tok: ["Implements","one","encoder","layer","in","DETR","transformer",".","Args",":","embed_dims","(","int",")",":","The","feature","dimension",".","Same","as","`","FFN","`",".","num_heads","(","int",")",":","Parallel","attention","heads",".","feedforward_channels","(","int",")",":","The","hidden","dimension","for","FFNs",".","dropout","(","float",")",":","Probability","of","an","element","to","be","zeroed",".","Default","0.0.","order","(","tuple","[","str","]",")",":","The","order","for","encoder","layer",".","Valid","examples","are","(","'selfattn","'",",","'norm","'",",","'ffn","'",",","'norm","'",")","and","(","'norm","'",",","'selfattn","'",",","'norm","'",",","'ffn","'",")",".","Default","(","'selfattn","'",",","'norm","'",",","'ffn","'",",","'norm","'",")",".","act_cfg","(","dict",")",":","The","activation","config","for","FFNs",".","Defalut","ReLU",".","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Default","layer","normalization",".","num_fcs","(","int",")",":","The","number","of","fully-connected","layers","for","FFNs",".","Default","2","."]
code: def __init__(
      self,
      embed_dims,
      num_heads,
      feedforward_channels,
      dropout=0.0,
      order=("selfattn", "norm", "ffn", "norm"),
      act_cfg=dict(type="ReLU", inplace=True),
      norm_cfg=dict(type="LN"),
      num_fcs=2,
  ):
      super(TransformerEncoderLayer, self).__init__()
      assert isinstance(order, tuple) and len(order) == 4
      assert set(order) == set(["selfattn", "norm", "ffn"])
      self.embed_dims = embed_dims
      self.num_heads = num_heads
      self.feedforward_channels = feedforward_channels
      self.dropout = dropout
      self.order = order
      self.act_cfg = act_cfg
      self.norm_cfg = norm_cfg
      self.num_fcs = num_fcs
      self.pre_norm = order[0] == "norm"
      self.self_attn = MultiheadAttention(
          embed_dims, num_heads, dropout
      )
      self.ffn = FFN(
          embed_dims, feedforward_channels, num_fcs, act_cfg, dropout
      )
      self.norms = nn.ModuleList()
      self.norms.append(build_norm_layer(norm_cfg, embed_dims)[1])
      self.norms.append(build_norm_layer(norm_cfg, embed_dims)[1])
  
imports: import torch
  import torch.nn
  from mmcv.cnn import Linear, build_activation_layer, build_norm_layer, xavier_init
  from .builder import TRANSFORMER
label_desc: Use image node_id 1 to create a new TransformerEncoderLayer object from inherited base classes: nn with example: obj = TransformerEncoderLayer(embed_dims, num_heads, feedforward_channels, dropout, order, act_cfg, norm_cfg, num_fcs)