code: def main(_):
      decode_hp = decode_hparams(FLAGS.decode_hparams)
      trainer_lib.set_random_seed(FLAGS.random_seed)
      if FLAGS.output_dir is None:
          raise ValueError(
              "Expected output_dir to be set to a valid path."
          )
  
      hparams = trainer_lib.create_hparams(
          FLAGS.hparams_set,
          FLAGS.hparams,
          data_dir=FLAGS.data_dir,
          problem_name=FLAGS.problem,
      )
      if hparams.batch_size != 1:
          raise ValueError("Set batch-size to be equal to 1")
  
      # prepare dataset using Predict mode.
      dataset_split = "test" if FLAGS.eval_use_test_set else None
      dataset = hparams.problem.dataset(
          tf_estimator.ModeKeys.PREDICT,
          shuffle_files=False,
          hparams=hparams,
          data_dir=FLAGS.data_dir,
          dataset_split=dataset_split,
      )
      dataset = dataset.batch(hparams.batch_size)
      dataset = dataset.make_one_shot_iterator().get_next()
  
      # Obtain frame interpolations.
      ops = [
          glow_ops.get_variable_ddi,
          glow_ops.actnorm,
          glow_ops.get_dropout,
      ]
      var_scope = tf.variable_scope(
          "next_frame_glow/body", reuse=tf.AUTO_REUSE
      )
      with arg_scope(ops, init=False), var_scope:
          interpolations, first_frame, last_frame = interpolate(
              dataset, hparams, decode_hp
          )
  
      var_list = tf.global_variables()
      saver = tf.train.Saver(var_list)
  
      # Get latest checkpoints from model_dir.
      ckpt_path = tf.train.latest_checkpoint(FLAGS.output_dir)
      final_dir = get_summaries_log_dir(
          decode_hp, FLAGS.output_dir, dataset_split
      )
      summary_writer = tf.summary.FileWriter(final_dir)
      global_step = decoding.latest_checkpoint_step(FLAGS.output_dir)
  
      sample_ind = 0
      num_samples = decode_hp.num_samples
      all_summaries = []
  
      with tf.train.MonitoredTrainingSession() as sess:
          saver.restore(sess, ckpt_path)
  
          while not sess.should_stop() and sample_ind < num_samples:
              interp_np, first_frame_np, last_frame_np = sess.run(
                  [interpolations, first_frame, last_frame]
              )
  
              interp_summ = interpolations_to_summary(
                  sample_ind,
                  interp_np,
                  first_frame_np[0],
                  last_frame_np[0],
                  hparams,
                  decode_hp,
              )
              all_summaries.extend(interp_summ)
              sample_ind += 1
          all_summaries = tf.Summary(value=list(all_summaries))
          summary_writer.add_summary(all_summaries, global_step)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl import flags
  import numpy
  from six.moves import zip
  from tensor2tensor.bin import t2t_trainer
  from tensor2tensor.data_generators import image_utils
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.models.research import glow_ops
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import decoding
  from tensor2tensor.utils import trainer_lib
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 8 for calling a global function with example usage: main(_) without return types