code: def main(_):
      tf.logging.set_verbosity(tf.logging.INFO)
      # pylint: disable=unused-variable
      model_dir = os.path.expanduser(FLAGS.model_dir)
      translations_dir = os.path.expanduser(FLAGS.translations_dir)
      source = os.path.expanduser(FLAGS.source)
      tf.gfile.MakeDirs(translations_dir)
      translated_base_file = os.path.join(
          translations_dir, FLAGS.problem
      )
  
      # Copy flags.txt with the original time, so t2t-bleu can report correct
      # relative time.
      flags_path = os.path.join(
          translations_dir, FLAGS.problem + "-flags.txt"
      )
      if not os.path.exists(flags_path):
          shutil.copy2(os.path.join(model_dir, "flags.txt"), flags_path)
  
      locals_and_flags = {"FLAGS": FLAGS}
      for model in bleu_hook.stepfiles_iterator(
          model_dir, FLAGS.wait_minutes, FLAGS.min_steps
      ):
          tf.logging.info("Translating " + model.filename)
          out_file = translated_base_file + "-" + str(model.steps)
          locals_and_flags.update(locals())
          if os.path.exists(out_file):
              tf.logging.info(
                  out_file + " already exists, so skipping it."
              )
          else:
              tf.logging.info("Translating " + out_file)
              params = (
                  "--t2t_usr_dir={FLAGS.t2t_usr_dir} --output_dir={model_dir} "
                  "--data_dir={FLAGS.data_dir} --problem={FLAGS.problem} "
                  "--decode_hparams=beam_size={FLAGS.beam_size},alpha={FLAGS.alpha} "
                  "--model={FLAGS.model} --hparams_set={FLAGS.hparams_set} "
                  "--checkpoint_path={model.filename} --decode_from_file={source} "
                  "--decode_to_file={out_file} --keep_timestamp"
              ).format(**locals_and_flags)
              command = FLAGS.decoder_command.format(**locals())
              tf.logging.info("Running:\n" + command)
              os.system(command)
  
file_path: tensor2tensor/tensor2tensor/bin/t2t_translate_all.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import shutil
  from tensor2tensor.utils import bleu_hook
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: main(_) without return types