code: def construct_model(
      images,
      actions=None,
      context_frames=2,
      hparams=None,
      is_training=True,
  ):
      """Constructs the tensorflow graph of the hierarchical model."""
  
      pred_depth = 20
  
      enc_out_all, pred_out_all, van_out_all, van_on_enc_all = (
          [],
          [],
          [],
          [],
      )
  
      lstm_states = [None] * (pred_depth + 2)
  
      enc_out = encoder_vgg(
          images[0],
          hparams.enc_size,
          False,
          scope_prefix="timestep/",
          hparams=hparams,
          is_training=is_training,
      )
      enc_out = tf.identity(enc_out, "enc_out")
      enc_out_all.append(enc_out)
  
      num_timesteps = len(actions) - 1
      sum_freq = int(num_timesteps / 4 + 1)
  
      reuse = False
      for timestep, action in zip(
          range(len(actions) - 1), actions[:-1]
      ):
          done_warm_start = timestep > context_frames - 1
  
          with tf.variable_scope("timestep", reuse=reuse):
              if done_warm_start:
                  pred_input = pred_out_all[-1]
              else:
                  pred_input = enc_out_all[-1]
              pred_out = predictor(
                  pred_input,
                  action,
                  lstm_states,
                  pred_depth,
                  False,
                  hparams=hparams,
              )
              pred_out = tf.identity(pred_out, "pred_out")
              if timestep % sum_freq == 0:  # and not hparams.use_tpu:
                  tf.summary.histogram("pred_out", pred_out)
              pred_out_all.append(pred_out)
  
              if timestep % sum_freq == 0:  # and not hparams.use_tpu:
                  tf.summary.histogram("lstm_state", lstm_states[0])
              van_out, _, _ = van(
                  enc_out_all[0],
                  images[0],
                  pred_out,
                  images[timestep + 1],
                  tf.AUTO_REUSE,
                  hparams=hparams,
              )
              van_out = tf.identity(van_out, "van_out")
              van_out_all.append(van_out)
  
              enc_out = encoder_vgg(
                  images[timestep + 1],
                  hparams.enc_size,
                  True,
                  hparams=hparams,
                  is_training=is_training,
              )
              enc_out = tf.identity(enc_out, "enc_out")
              if timestep % sum_freq == 0:  # and not hparams.use_tpu:
                  tf.summary.histogram("enc_out", enc_out)
              enc_out_all.append(enc_out)
  
              van_input = images[0]
              enc_noise = tf.zeros_like(enc_out)
              if timestep % sum_freq == 0:  # and not hparams.use_tpu:
                  tf.summary.histogram("enc_noise", enc_noise)
              van_on_enc, _, _ = van(
                  enc_out_all[0],
                  van_input,
                  enc_out + enc_noise,
                  images[timestep + 1],
                  tf.AUTO_REUSE,
                  hparams=hparams,
              )
              van_on_enc = tf.identity(van_on_enc, "van_on_enc")
              van_on_enc_all.append(van_on_enc)
  
              reuse = True
  
      return enc_out_all, pred_out_all, van_out_all, van_on_enc_all
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import reduce
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import common_video
  from tensor2tensor.models.video import epva_params
  from tensor2tensor.models.video import sv2p
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
  from tensorflow.contrib.framework.python.ops import arg_scope
  from tensorflow.contrib.slim.python.slim.nets import vgg
label_desc: Use image node_id 8 for calling a global function with example usage: construct_model(images, actions, context_frames, hparams, is_training) and returns: enc_out_all,  pred_out_all,  van_out_all,  van_on_enc_all