code: def generator(input, batch_size, timesteps, encoder):
      """Generate batch with respect to input (a list). Encode its
      strings to integers, returning an array of shape [batch_size, timesteps].
      """
      while True:
          imb = np.random.randint(0, len(input) - timesteps, batch_size)
          encoded = np.asarray(
              [
                  [encoder[c] for c in input[i : (i + timesteps)]]
                  for i in imb
              ],
              dtype=np.int32,
          )
          yield encoded
  
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 2 for calling a global function with example usage: generator(input, batch_size, timesteps, encoder) without return types