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: :param tokens: ``[batch_size, max_len]``
  :param state: ``state`` 包含了 ``encoder`` 的输出以及 ``decode`` 之前的内容
  :return: 返回值可以为 ``[batch_size, max_len, vocab_size]`` 的张量，也可以是一个 :class:`list`，但是第一个元素必须是词的预测分布
docstr_tok: [":","param","tokens",":","``","[","batch_size",",","max_len","]","``",":","param","state",":","``","state","``","\u5305\u542b\u4e86","``","encoder","``","\u7684\u8f93\u51fa\u4ee5\u53ca","``","decode","``","\u4e4b\u524d\u7684\u5185\u5bb9",":","return",":","\u8fd4\u56de\u503c\u53ef\u4ee5\u4e3a","``","[","batch_size",",","max_len",",","vocab_size","]","``","\u7684\u5f20\u91cf\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a",":","class",":","`","list","`","\uff0c\u4f46\u662f\u7b2c\u4e00\u4e2a\u5143\u7d20\u5fc5\u987b\u662f\u8bcd\u7684\u9884\u6d4b\u5206\u5e03"]
code: def forward(self, tokens: "torch.LongTensor", state: State, **kwargs):
      """
  
      :param tokens: ``[batch_size, max_len]``
      :param state: ``state`` 包含了 ``encoder`` 的输出以及 ``decode`` 之前的内容
      :return: 返回值可以为 ``[batch_size, max_len, vocab_size]`` 的张量，也可以是一个 :class:`list`，但是第一个元素必须是词的预测分布
      """
      raise NotImplemented
  
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 2 for calling the Seq2SeqDecoder obj's underlying member method code with example usage: obj.forward(tokens, state) without return types