class_docstr: 与 :class:`~fastNLP.modules.torch.decoder.TransformerSeq2SeqDecoder` 对应的 :class:`State`。
  
  :param encoder_output: ``encoder`` 的输出，形状为 ``[batch_size, encode_max_len, encode_output_size]``，
  :param encoder_mask: 掩码，形状为 ``[batch_size, encode_max_len]``，为 **1** 的地方表示需要 attend
  :param num_decoder_layer: decoder 层数
class_docstr_tok: ["\u4e0e",":","class",":","`","~fastNLP.modules.torch.decoder.TransformerSeq2SeqDecoder","`","\u5bf9\u5e94\u7684",":","class",":","`","State","`","\u3002",":","param","encoder_output",":","``","encoder","``","\u7684\u8f93\u51fa\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","encode_max_len",",","encode_output_size","]","``","\uff0c",":","param","encoder_mask",":","\u63a9\u7801\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","encode_max_len","]","``","\uff0c\u4e3a","*","*","1","*","*","\u7684\u5730\u65b9\u8868\u793a\u9700\u8981","attend",":","param","num_decoder_layer",":","decoder","\u5c42\u6570"]
code: def __init__(
      self,
      encoder_output: torch.FloatTensor,
      encoder_mask: torch.FloatTensor,
      num_decoder_layer: int,
  ):
      super().__init__(encoder_output, encoder_mask)
      self.encoder_key = [
          None
      ] * num_decoder_layer  # 每一个元素 bsz x encoder_max_len x key_dim
      self.encoder_value = [
          None
      ] * num_decoder_layer  # 每一个元素 bsz x encoder_max_len x value_dim
      self.decoder_prev_key = [
          None
      ] * num_decoder_layer  # 每一个元素 bsz x decode_length x key_dim
      self.decoder_prev_value = [None] * num_decoder_layer
  
file_path: fastNLP/fastNLP/modules/torch/decoder/seq2seq_state.py
imports: from typing import Union, List, Tuple
  import torch
label_desc: Use image node_id 1 to create a new TransformerState object from inherited base classes: State with example: obj = TransformerState(encoder_output, encoder_mask, num_decoder_layer)