code: def generator(array, batch_size):
      """Generate batch with respect to array's first axis."""
      start = 0  # pointer to where we are in iteration
      while True:
          stop = start + batch_size
          diff = stop - array.shape[0]
          if diff <= 0:
              batch = array[start:stop]
              start += batch_size
          else:
              batch = np.concatenate((array[start:], array[:diff]))
              start = diff
          batch = (
              batch.astype(np.float32) / 255.0
          )  # normalize pixel intensities
          batch = np.random.binomial(1, batch)  # binarize images
          yield batch
  
file_path: edward/examples/vae.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import edward
  import numpy
  import os
  import tensorflow
  from edward.models import Bernoulli, Normal
  from edward.util import Progbar
  from observations import mnist
  from scipy.misc import imsave
label_desc: Use image node_id 1 for calling a global function with example usage: generator(array, batch_size) without return types