class_docstr: 可以用于在 :class:`~fastNLP.core.controllers.Trainer` 中训练的 **Seq2Seq模型** 。正常情况下，继承了该函数之后，只需要
  实现 classmethod ``build_model`` 即可。如果需要使用该模型进行生成，需要把该模型输入到 :class:`~fastNLP.models.torch.SequenceGeneratorModel`
  中。在本模型中， :meth:`forward` 会把 encoder 后的结果传入到 decoder 中，并将 decoder 的输出 output 出来。
  
  :param encoder: :class:`~fastNLP.modules.torch.encoder.Seq2SeqEncoder` 对象，需要实现对应的 :meth:`forward` 函数，接受两个参数，第一个为
      ``[batch_size, max_len]`` 的 source tokens, 第二个为 ``[batch_size,]`` 的 source 的长度；需要返回两个 tensor： 
      
          - ``encoder_outputs`` : ``[batch_size, max_len, hidden_size]``
          - ``encoder_mask`` :  ``[batch_size, max_len]``，为 **0** 的地方为 pad。
      如果encoder的输出或者输入有变化，可以重载本模型的 :meth:`prepare_state` 函数或者 :meth:`forward` 函数。
  :param decoder: :class:`~fastNLP.modules.torch.decoder.Seq2SeqEncoder` 对象，需要实现 :meth:`init_state` 函数，需要接受两个参数，分别为
      上述的 ``encoder_outputs`` 和 ``encoder_mask``。若decoder需要更多输入，请重载当前模型的 :meth:`prepare_state` 或 :meth:`forward` 函数。
docstr: :param src_tokens: source 的 token，形状为 ``[batch_size, max_len]``
  :param tgt_tokens: target 的 token，形状为 ``[batch_size, max_len]``
  :param src_seq_len: source的长度，形状为 ``[batch_size,]``
  :param tgt_seq_len: target的长度，形状为 ``[batch_size,]``
  :return: 字典 ``{'pred': torch.Tensor}``, 其中 ``pred`` 的形状为 ``[batch_size, max_len, vocab_size]``
docstr_tok: [":","param","src_tokens",":","source","\u7684","token\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","max_len","]","``",":","param","tgt_tokens",":","target","\u7684","token\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","max_len","]","``",":","param","src_seq_len",":","source\u7684\u957f\u5ea6\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","]","``",":","param","tgt_seq_len",":","target\u7684\u957f\u5ea6\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","]","``",":","return",":","\u5b57\u5178","``","{","'pred","'",":","torch.Tensor","}","``",",","\u5176\u4e2d","``","pred","``","\u7684\u5f62\u72b6\u4e3a","``","[","batch_size",",","max_len",",","vocab_size","]","``"]
code: def forward(
      self,
      src_tokens: "torch.LongTensor",
      tgt_tokens: "torch.LongTensor",
      src_seq_len: "torch.LongTensor" = None,
      tgt_seq_len: "torch.LongTensor" = None,
  ):
      """
      :param src_tokens: source 的 token，形状为 ``[batch_size, max_len]``
      :param tgt_tokens: target 的 token，形状为 ``[batch_size, max_len]``
      :param src_seq_len: source的长度，形状为 ``[batch_size,]``
      :param tgt_seq_len: target的长度，形状为 ``[batch_size,]``
      :return: 字典 ``{'pred': torch.Tensor}``, 其中 ``pred`` 的形状为 ``[batch_size, max_len, vocab_size]``
      """
      state = self.prepare_state(src_tokens, src_seq_len)
      decoder_output = self.decoder(tgt_tokens, state)
      if isinstance(decoder_output, torch.Tensor):
          return {"pred": decoder_output}
      elif isinstance(decoder_output, (tuple, list)):
          return {"pred": decoder_output[0]}
      else:
          raise TypeError(
              f"Unsupported return type from Decoder:{type(self.decoder)}"
          )
  
imports: import torch
  from torch import nn
  import torch.nn.functional
  from fastNLP import seq_len_to_mask
  from ...embeddings.torch.utils import get_embeddings
  from ...embeddings.torch.utils import get_sinusoid_encoding_table
  from ...modules.torch.decoder.seq2seq_decoder import Seq2SeqDecoder, TransformerSeq2SeqDecoder, LSTMSeq2SeqDecoder
  from ...modules.torch.encoder.seq2seq_encoder import Seq2SeqEncoder, TransformerSeq2SeqEncoder, LSTMSeq2SeqEncoder
label_desc: Use image node_id 2 for calling the Seq2SeqModel obj's underlying member method code with example usage: obj.forward(src_tokens, tgt_tokens, src_seq_len, tgt_seq_len) and returns: dict, dict