class_docstr: Implements the encoder in DETR transformer.
  
  Args:
      num_layers (int): The number of `TransformerEncoderLayer`.
      embed_dims (int): Same as `TransformerEncoderLayer`.
      num_heads (int): Same as `TransformerEncoderLayer`.
      feedforward_channels (int): Same as `TransformerEncoderLayer`.
      dropout (float): Same as `TransformerEncoderLayer`. Default 0.0.
      order (tuple[str]): Same as `TransformerEncoderLayer`.
      act_cfg (dict): Same as `TransformerEncoderLayer`. Defalut ReLU.
      norm_cfg (dict): Same as `TransformerEncoderLayer`. Default
          layer normalization.
      num_fcs (int): Same as `TransformerEncoderLayer`. Default 2.
class_docstr_tok: ["Implements","the","encoder","in","DETR","transformer",".","Args",":","num_layers","(","int",")",":","The","number","of","`","TransformerEncoderLayer","`",".","embed_dims","(","int",")",":","Same","as","`","TransformerEncoderLayer","`",".","num_heads","(","int",")",":","Same","as","`","TransformerEncoderLayer","`",".","feedforward_channels","(","int",")",":","Same","as","`","TransformerEncoderLayer","`",".","dropout","(","float",")",":","Same","as","`","TransformerEncoderLayer","`",".","Default","0.0.","order","(","tuple","[","str","]",")",":","Same","as","`","TransformerEncoderLayer","`",".","act_cfg","(","dict",")",":","Same","as","`","TransformerEncoderLayer","`",".","Defalut","ReLU",".","norm_cfg","(","dict",")",":","Same","as","`","TransformerEncoderLayer","`",".","Default","layer","normalization",".","num_fcs","(","int",")",":","Same","as","`","TransformerEncoderLayer","`",".","Default","2","."]
docstr: Forward function for `TransformerEncoder`.
  
  Args:
      x (Tensor): Input query. Same in `TransformerEncoderLayer.forward`.
      pos (Tensor): Positional encoding for query. Default None.
          Same in `TransformerEncoderLayer.forward`.
      attn_mask (Tensor): ByteTensor attention mask. Default None.
          Same in `TransformerEncoderLayer.forward`.
      key_padding_mask (Tensor): Same in
          `TransformerEncoderLayer.forward`. Default None.
  
  Returns:
      Tensor: Results with shape [num_key, bs, embed_dims].
docstr_tok: ["Forward","function","for","`","TransformerEncoder","`",".","Args",":","x","(","Tensor",")",":","Input","query",".","Same","in","`","TransformerEncoderLayer.forward","`",".","pos","(","Tensor",")",":","Positional","encoding","for","query",".","Default","None",".","Same","in","`","TransformerEncoderLayer.forward","`",".","attn_mask","(","Tensor",")",":","ByteTensor","attention","mask",".","Default","None",".","Same","in","`","TransformerEncoderLayer.forward","`",".","key_padding_mask","(","Tensor",")",":","Same","in","`","TransformerEncoderLayer.forward","`",".","Default","None",".","Returns",":","Tensor",":","Results","with","shape","[","num_key",",","bs",",","embed_dims","]","."]
code: def forward(self, x, pos=None, attn_mask=None, key_padding_mask=None):
      """Forward function for `TransformerEncoder`.
  
      Args:
          x (Tensor): Input query. Same in `TransformerEncoderLayer.forward`.
          pos (Tensor): Positional encoding for query. Default None.
              Same in `TransformerEncoderLayer.forward`.
          attn_mask (Tensor): ByteTensor attention mask. Default None.
              Same in `TransformerEncoderLayer.forward`.
          key_padding_mask (Tensor): Same in
              `TransformerEncoderLayer.forward`. Default None.
  
      Returns:
          Tensor: Results with shape [num_key, bs, embed_dims].
      """
      for layer in self.layers:
          x = layer(x, pos, attn_mask, key_padding_mask)
      if self.norm is not None:
          x = self.norm(x)
      return x
  
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 2 for calling the TransformerEncoder obj's underlying member method code with example usage: obj.forward(x, pos, attn_mask, key_padding_mask) and returns: x