class_docstr: **Self-Attention** 的 Layer，
  
  :param int d_model: input和output的输出维度
  :param int n_head: 多少个head，每个head的维度为d_model/n_head
  :param int dim_ff: FFN的维度大小
  :param float dropout: Self-attention和FFN的dropout大小，0表示不drop
class_docstr_tok: ["*","*","Self-Attention","*","*","\u7684","Layer\uff0c",":","param","int","d_model",":","input\u548coutput\u7684\u8f93\u51fa\u7ef4\u5ea6",":","param","int","n_head",":","\u591a\u5c11\u4e2ahead\uff0c\u6bcf\u4e2ahead\u7684\u7ef4\u5ea6\u4e3ad_model\/n_head",":","param","int","dim_ff",":","FFN\u7684\u7ef4\u5ea6\u5927\u5c0f",":","param","float","dropout",":","Self-attention\u548cFFN\u7684dropout\u5927\u5c0f\uff0c0\u8868\u793a\u4e0ddrop"]
code: def __init__(
      self,
      d_model: int = 512,
      n_head: int = 8,
      dim_ff: int = 2048,
      dropout: float = 0.1,
  ):
      super(TransformerSeq2SeqEncoderLayer, self).__init__()
      self.d_model = d_model
      self.n_head = n_head
      self.dim_ff = dim_ff
      self.dropout = dropout
  
      self.self_attn = MultiHeadAttention(d_model, n_head, dropout)
      self.attn_layer_norm = LayerNorm(d_model)
      self.ffn_layer_norm = LayerNorm(d_model)
  
      self.ffn = nn.Sequential(
          nn.Linear(self.d_model, self.dim_ff),
          nn.ReLU(),
          nn.Dropout(dropout),
          nn.Linear(self.dim_ff, self.d_model),
          nn.Dropout(dropout),
      )
  
imports: import torch.nn
  import torch
  from torch.nn import LayerNorm
  import torch.nn.functional
  from typing import Union, Tuple
  from ....core.utils import seq_len_to_mask
  import math
  from .lstm import LSTM
  from ..attention import MultiHeadAttention
  from ....embeddings.torch import StaticEmbedding
  from ....embeddings.torch.utils import get_embeddings
label_desc: Use image node_id 1 to create a new TransformerSeq2SeqEncoderLayer object from inherited base classes: nn with example: obj = TransformerSeq2SeqEncoderLayer(d_model, n_head, dim_ff, dropout)