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","."]
code: def __init__(
      self,
      num_layers,
      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(TransformerEncoder, self).__init__()
      assert isinstance(order, tuple) and len(order) == 4
      assert set(order) == set(["selfattn", "norm", "ffn"])
      self.num_layers = num_layers
      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.layers = nn.ModuleList()
      for _ in range(num_layers):
          self.layers.append(
              TransformerEncoderLayer(
                  embed_dims,
                  num_heads,
                  feedforward_channels,
                  dropout,
                  order,
                  act_cfg,
                  norm_cfg,
                  num_fcs,
              )
          )
      self.norm = (
          build_norm_layer(norm_cfg, embed_dims)[1]
          if self.pre_norm
          else None
      )
  
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 TransformerEncoder object from inherited base classes: nn with example: obj = TransformerEncoder(num_layers, embed_dims, num_heads, feedforward_channels, dropout, order, act_cfg, norm_cfg, num_fcs)