code: def main(argv):
      tf.logging.set_verbosity(tf.logging.INFO)
      trainer_lib.set_random_seed(FLAGS.random_seed)
      usr_dir.import_usr_dir(FLAGS.t2t_usr_dir)
      t2t_trainer.maybe_log_registry_and_exit()
  
      if FLAGS.generate_data:
          t2t_trainer.generate_data()
  
      if argv:
          t2t_trainer.set_hparams_from_args(argv[1:])
      hparams = t2t_trainer.create_hparams()
      trainer_lib.add_problem_hparams(hparams, FLAGS.problem)
      pruning_params = create_pruning_params()
      pruning_strategy = create_pruning_strategy(
          pruning_params.strategy
      )
  
      config = t2t_trainer.create_run_config(hparams)
      params = {"batch_size": hparams.batch_size}
  
      # add "_rev" as a hack to avoid image standardization
      problem = registry.problem(FLAGS.problem)
      input_fn = problem.make_estimator_input_fn(
          tf_estimator.ModeKeys.EVAL, hparams
      )
      dataset = input_fn(params, config).repeat()
      features, labels = dataset.make_one_shot_iterator().get_next()
  
      sess = tf.Session()
  
      model_fn = t2t_model.T2TModel.make_estimator_model_fn(
          FLAGS.model, hparams, use_tpu=FLAGS.use_tpu
      )
      spec = model_fn(
          features,
          labels,
          tf_estimator.ModeKeys.EVAL,
          params=hparams,
          config=config,
      )
  
      # Restore weights
      saver = tf.train.Saver()
      checkpoint_path = os.path.expanduser(
          FLAGS.output_dir or FLAGS.checkpoint_path
      )
      saver.restore(sess, tf.train.latest_checkpoint(checkpoint_path))
  
      def eval_model():
          preds = spec.predictions["predictions"]
          preds = tf.argmax(preds, -1, output_type=labels.dtype)
          _, acc_update_op = tf.metrics.accuracy(
              labels=labels, predictions=preds
          )
          sess.run(tf.initialize_local_variables())
          for _ in range(FLAGS.eval_steps):
              acc = sess.run(acc_update_op)
          return acc
  
      pruning_utils.sparsify(
          sess, eval_model, pruning_strategy, pruning_params
      )
  
file_path: tensor2tensor/tensor2tensor/bin/t2t_prune.py
imports: import os
  from tensor2tensor.bin import t2t_trainer
  from tensor2tensor.data_generators import problem
  from tensor2tensor.utils import pruning_utils
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  from tensor2tensor.utils import trainer_lib
  from tensor2tensor.utils import usr_dir
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 3 for calling a global function with example usage: main(argv) and returns: acc