code: def test_run(self):
      # 测试能否运行 (1) 初始化decoder，(2) decode一发
      embed, encoder_output, encoder_mask = prepare_env()
  
      for do_sample in [True, False]:
          for num_beams in [1, 3, 5]:
              decoder = LSTMSeq2SeqDecoder(
                  embed=embed,
                  num_layers=1,
                  hidden_size=10,
                  dropout=0.3,
                  bind_decoder_input_output_embed=True,
                  attention=True,
              )
              state = decoder.init_state(encoder_output, encoder_mask)
              generator = SequenceGenerator(
                  decoder=decoder,
                  max_length=20,
                  num_beams=num_beams,
                  do_sample=do_sample,
                  temperature=1.0,
                  top_k=50,
                  top_p=1.0,
                  bos_token_id=1,
                  eos_token_id=None,
                  repetition_penalty=1,
                  length_penalty=1.0,
                  pad_token_id=0,
              )
              generator.generate(state=state, tokens=None)
  
              decoder = TransformerSeq2SeqDecoder(
                  embed=embed,
                  pos_embed=nn.Embedding(10, embed.embedding_dim),
                  d_model=encoder_output.size(-1),
                  num_layers=2,
                  n_head=2,
                  dim_ff=10,
                  dropout=0.1,
                  bind_decoder_input_output_embed=True,
              )
              state = decoder.init_state(encoder_output, encoder_mask)
              generator = SequenceGenerator(
                  decoder=decoder,
                  max_length=5,
                  num_beams=num_beams,
                  do_sample=do_sample,
                  temperature=1.0,
                  top_k=50,
                  top_p=1.0,
                  bos_token_id=1,
                  eos_token_id=None,
                  repetition_penalty=1,
                  length_penalty=1.0,
                  pad_token_id=0,
              )
              generator.generate(state=state, tokens=None)
  
              # 测试一下其它值
              decoder = TransformerSeq2SeqDecoder(
                  embed=embed,
                  pos_embed=nn.Embedding(10, embed.embedding_dim),
                  d_model=encoder_output.size(-1),
                  num_layers=2,
                  n_head=2,
                  dim_ff=10,
                  dropout=0.1,
                  bind_decoder_input_output_embed=True,
              )
              state = decoder.init_state(encoder_output, encoder_mask)
              generator = SequenceGenerator(
                  decoder=decoder,
                  max_length=5,
                  num_beams=num_beams,
                  do_sample=do_sample,
                  temperature=0.9,
                  top_k=50,
                  top_p=0.5,
                  bos_token_id=1,
                  eos_token_id=3,
                  repetition_penalty=2,
                  length_penalty=1.5,
                  pad_token_id=0,
              )
              generator.generate(state=state, tokens=None)
  
file_path: fastNLP/tests/modules/torch/generator/test_seq2seq_generator.py
imports: import pytest
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
label_desc: Use image node_id 1 for calling the TestSequenceGenerator obj's underlying member method code with example usage: obj.test_run() without return types