class_docstr: **Sequence-to-Sequence Decoder** 的基类。一定需要实现 :meth:`forward` 和 :meth:`decode` 函数，剩下的函数根据需要实现。每个 ``Seq2SeqDecoder`` 都应该有相应的
  :class:`~fastNLP.modules.torch.decoder.State` 对象用来承载该 ``Decoder`` 所需要的 ``Encoder`` 输出、``Decoder`` 需要记录的历史信（例如 :class:`~fastNLP.modules.torch.encoder.LSTM`
  的 hidden 信息）。
class_docstr_tok: ["*","*","Sequence-to-Sequence","Decoder","*","*","\u7684\u57fa\u7c7b\u3002\u4e00\u5b9a\u9700\u8981\u5b9e\u73b0",":","meth",":","`","forward","`","\u548c",":","meth",":","`","decode","`","\u51fd\u6570\uff0c\u5269\u4e0b\u7684\u51fd\u6570\u6839\u636e\u9700\u8981\u5b9e\u73b0\u3002\u6bcf\u4e2a","``","Seq2SeqDecoder","``","\u90fd\u5e94\u8be5\u6709\u76f8\u5e94\u7684",":","class",":","`","~fastNLP.modules.torch.decoder.State","`","\u5bf9\u8c61\u7528\u6765\u627f\u8f7d\u8be5","``","Decoder","``","\u6240\u9700\u8981\u7684","``","Encoder","``","\u8f93\u51fa\u3001","``","Decoder","``","\u9700\u8981\u8bb0\u5f55\u7684\u5386\u53f2\u4fe1\uff08\u4f8b\u5982",":","class",":","`","~fastNLP.modules.torch.encoder.LSTM","`","\u7684","hidden","\u4fe1\u606f\uff09\u3002"]
docstr: 根据 ``states`` 中的内容，以及 ``tokens`` 中的内容进行之后的生成。
  
  :param tokens: ``[batch_size, max_len]``，截止到上一个时刻所有的 token 输出。
  :param state: 记录了 ``encoder`` 输出与 ``decoder`` 过去状态
  :return: `下一个时刻的分布，形状为 ``[batch_size, vocab_size]``
docstr_tok: ["\u6839\u636e","``","states","``","\u4e2d\u7684\u5185\u5bb9\uff0c\u4ee5\u53ca","``","tokens","``","\u4e2d\u7684\u5185\u5bb9\u8fdb\u884c\u4e4b\u540e\u7684\u751f\u6210\u3002",":","param","tokens",":","``","[","batch_size",",","max_len","]","``","\uff0c\u622a\u6b62\u5230\u4e0a\u4e00\u4e2a\u65f6\u523b\u6240\u6709\u7684","token","\u8f93\u51fa\u3002",":","param","state",":","\u8bb0\u5f55\u4e86","``","encoder","``","\u8f93\u51fa\u4e0e","``","decoder","``","\u8fc7\u53bb\u72b6\u6001",":","return",":","`","\u4e0b\u4e00\u4e2a\u65f6\u523b\u7684\u5206\u5e03\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","vocab_size","]","``"]
code: def decode(
      self, tokens: torch.LongTensor, state
  ) -> torch.FloatTensor:
      """
      根据 ``states`` 中的内容，以及 ``tokens`` 中的内容进行之后的生成。
  
      :param tokens: ``[batch_size, max_len]``，截止到上一个时刻所有的 token 输出。
      :param state: 记录了 ``encoder`` 输出与 ``decoder`` 过去状态
      :return: `下一个时刻的分布，形状为 ``[batch_size, vocab_size]``
      """
      outputs = self(state=state, tokens=tokens)
      if isinstance(outputs, torch.Tensor):
          return outputs[:, -1]
      else:
          raise RuntimeError(
              "Unrecognized output from the `forward()` function. Please override the `decode()` function."
          )
  
imports: from typing import Union, Tuple
  import math
  import torch
  from torch import nn
  import torch.nn.functional
  from ..attention import AttentionLayer, MultiHeadAttention
  from ....embeddings.torch.utils import get_embeddings
  from ....embeddings.torch.static_embedding import StaticEmbedding
  from .seq2seq_state import State, LSTMState, TransformerState
label_desc: Use image node_id 5 for calling the Seq2SeqDecoder obj's underlying member method code with example usage: obj.decode(tokens, state) and returns: outputs