code: def language_model(input, vocab_size):
      """Form p(x[0], ..., x[timesteps - 1]),
  
      \prod_{t=0}^{timesteps - 1} p(x[t] | x[:t]),
  
      To calculate the probability, we call log_prob on
      x = [x[0], ..., x[timesteps - 1]] given
      `input` = [0, x[0], ..., x[timesteps - 2]].
  
      We implement this separately from the generative model so the
      forward pass, e.g., embedding/dense layers, can be parallelized.
  
      [batch_size, timesteps] -> [batch_size, timesteps]
      """
      x = tf.one_hot(input, depth=vocab_size, dtype=tf.float32)
      h = tf.fill(tf.stack([tf.shape(x)[0], FLAGS.hidden_size]), 0.0)
      c = tf.fill(tf.stack([tf.shape(x)[0], FLAGS.hidden_size]), 0.0)
      hs = []
      reuse = None
      for t in range(FLAGS.timesteps):
          if t > 0:
              reuse = True
          xt = x[:, t, :]
          h, c = lstm_cell(xt, h, c, name="lstm", reuse=reuse)
          hs.append(h)
  
      h = tf.stack(hs, 1)
      logits = tf.layers.dense(h, vocab_size, name="dense")
      output = Categorical(logits=logits)
      return output
  
file_path: edward/examples/lstm.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import edward
  import numpy
  import os
  import string
  import tensorflow
  from datetime import datetime
  from edward.models import Categorical
  from edward.util import Progbar
  from observations import text8
label_desc: Use image node_id 3 for calling a global function with example usage: language_model(input, vocab_size) and returns: output