code: def __init__(
      self,
      n_layers=2,
      n_head=8,
      d_word_vec=512,
      d_k=64,
      d_v=64,
      d_model=512,
      d_inner=2048,
      dropout=0.1,
      n_position=256,
  ):
      super(Transformer_Encoder, self).__init__()
      self.position_enc = PositionalEncoding(
          d_word_vec, n_position=n_position
      )
      self.dropout = nn.Dropout(p=dropout)
      self.layer_stack = nn.LayerList(
          [
              EncoderLayer(
                  d_model, d_inner, n_head, d_k, d_v, dropout=dropout
              )
              for _ in range(n_layers)
          ]
      )
      self.layer_norm = nn.LayerNorm(d_model, epsilon=1e-6)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal, XavierNormal
  import numpy
label_desc: Use image node_id 1 to create a new Transformer_Encoder object from inherited base classes: nn with example: obj = Transformer_Encoder(n_layers, n_head, d_word_vec, d_k, d_v, d_model, d_inner, dropout, n_position)