class_docstr: Transformer model for simultaneous translation.
code: def __init__(
      self,
      max_length=256,
      max_out_len=256,
  ):
      super(STTransformer, self).__init__()
      bpe_codes_fpath = os.path.join(
          MODULE_HOME,
          "transformer_nist_wait_3",
          "assets",
          "2M.zh2en.dict4bpe.zh",
      )
      src_vocab_fpath = os.path.join(
          MODULE_HOME,
          "transformer_nist_wait_3",
          "assets",
          "nist.20k.zh.vocab",
      )
      trg_vocab_fpath = os.path.join(
          MODULE_HOME,
          "transformer_nist_wait_3",
          "assets",
          "nist.10k.en.vocab",
      )
      params_fpath = os.path.join(
          MODULE_HOME,
          "transformer_nist_wait_3",
          "assets",
          "transformer.pdparams",
      )
      self.max_length = max_length
      self.max_out_len = max_out_len
      self.tokenizer = STACLTokenizer(
          bpe_codes_fpath,
          src_vocab_fpath,
          trg_vocab_fpath,
      )
      src_vocab_size = self.tokenizer.src_vocab_size
      trg_vocab_size = self.tokenizer.trg_vocab_size
      self.transformer = SimultaneousTransformer(
          src_vocab_size,
          trg_vocab_size,
          max_length=self.max_length,
          n_layer=self.model_config["n_layer"],
          n_head=self.model_config["n_head"],
          d_model=self.model_config["d_model"],
      )
      model_dict = paddle.load(params_fpath)
      # To avoid a longer length than training, reset the size of position
      # encoding to max_length
      model_dict[
          "src_pos_embedding.pos_encoder.weight"
      ] = position_encoding_init(
          self.max_length + 1, self.model_config["d_model"]
      )
      model_dict[
          "trg_pos_embedding.pos_encoder.weight"
      ] = position_encoding_init(
          self.max_length + 1, self.model_config["d_model"]
      )
      self.transformer.load_dict(model_dict)
  
file_path: PaddleHub/modules/text/simultaneous_translation/stacl/transformer_nist_wait_3/module.py
imports: import os
  import jieba
  import paddle
  from paddlenlp.transformers import position_encoding_init
  from paddlenlp.transformers import WordEmbedding, PositionalEmbedding
  from paddlehub.env import MODULE_HOME
  from paddlehub.module.module import moduleinfo, serving
  from transformer_nist_wait_3.model import SimultaneousTransformer
  from transformer_nist_wait_3.processor import STACLTokenizer, predict
label_desc: Use image node_id 1 to create a new STTransformer object  with example: obj = STTransformer(max_length, max_out_len)