code: def test_glow_inference(self):
      hparams = glow.glow_hparams()
      hparams.depth = 15
      hparams.n_levels = 2
      hparams.data_dir = ""
      curr_dir = tempfile.mkdtemp()
  
      # Training pipeline
      with tf.Graph().as_default():
          cifar_problem = problems.problem(
              "image_cifar10_plain_random_shift"
          )
          hparams.problem = cifar_problem
          model = glow.Glow(hparams, tf_estimator.ModeKeys.TRAIN)
          train_dataset = cifar_problem.dataset(MODES.TRAIN)
          one_shot = train_dataset.make_one_shot_iterator()
          x_batch, y_batch = self.batch(one_shot)
          features = {"inputs": x_batch, "targets": y_batch}
          model_path = os.path.join(curr_dir, "model")
          model(features)
  
          with tf.Session() as session:
              saver = tf.train.Saver()
              session.run(tf.global_variables_initializer())
  
              init_op = tf.get_collection("glow_init_op")
              session.run(init_op)
              z = session.run([model.z])
              mean_z = np.mean(z)
              is_undefined = np.isnan(mean_z) or np.isinf(mean_z)
              self.assertTrue(not is_undefined)
              saver.save(session, model_path)
  
      # Inference pipeline
      with tf.Graph().as_default():
          cifar_problem = problems.problem(
              "image_cifar10_plain_random_shift"
          )
          hparams.problem = cifar_problem
          model = glow.Glow(hparams, tf_estimator.ModeKeys.PREDICT)
          test_dataset = cifar_problem.dataset(MODES.EVAL)
          one_shot = test_dataset.make_one_shot_iterator()
          x_batch, y_batch = self.batch(one_shot)
          features = {"inputs": x_batch, "targets": y_batch}
          model_path = os.path.join(curr_dir, "model")
  
          predictions = model.infer(features)
          with tf.Session() as session:
              saver = tf.train.Saver()
              saver.restore(session, model_path)
              predictions_np = session.run(predictions)
              self.assertTrue(np.all(predictions_np <= 255))
              self.assertTrue(np.all(predictions_np >= 0))
  
file_path: tensor2tensor/tensor2tensor/models/research/glow_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import tempfile
  import numpy
  from six.moves import range
  from tensor2tensor import problems
  from tensor2tensor.data_generators import cifar
  from tensor2tensor.models.research import glow
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 3 for calling the GlowModelTest obj's underlying member method code with example usage: obj.test_glow_inference() without return types