code: def predict(
      tokenized_src,
      decoder_max_length,
      is_last,
      cache,
      bos_id,
      result,
      tokenizer,
      transformer,
      n_best=1,
      max_out_len=256,
      eos_idx=1,
      waitk=-1,
  ):
      # Set evaluate mode
      transformer.eval()
  
      if not is_last:
          return result, cache, bos_id
  
      with paddle.no_grad():
          paddle.disable_static()
          input_src = tokenized_src
          if is_last:
              decoder_max_length = max_out_len
              input_src += [eos_idx]
          src_word = paddle.to_tensor(input_src).unsqueeze(axis=0)
          (
              finished_seq,
              finished_scores,
              cache,
          ) = transformer.greedy_search(
              src_word,
              max_len=decoder_max_length,
              waitk=waitk,
              caches=cache,
              bos_id=bos_id,
          )
          finished_seq = finished_seq.numpy()
          for beam_idx, beam in enumerate(finished_seq[0]):
              if beam_idx >= n_best:
                  break
              id_list = post_process_seq(beam)
              if len(id_list) == 0:
                  continue
              bos_id = id_list[-1]
              word_list = tokenizer.trg_vocab.to_tokens(id_list)
              for word in word_list:
                  result.append(word)
              res = " ".join(word_list).replace("@@ ", "")
          paddle.enable_static()
      return result, cache, bos_id
  
file_path: PaddleHub/modules/text/simultaneous_translation/stacl/transformer_nist_wait_all/processor.py
imports: import paddle
  from paddlenlp.data import Vocab
  from subword_nmt import subword_nmt
label_desc: Use image node_id 2 for calling a global function with example usage: predict(tokenized_src, decoder_max_length, is_last, cache, bos_id, result, tokenizer, transformer, n_best, max_out_len, eos_idx, waitk) and returns: result,  cache,  bos_id, result,  cache,  bos_id