code: def load_bernoulli_mnist_dataset(directory, split_name):
      """Returns Hugo Larochelle's binary static MNIST tf.data.Dataset."""
      amat_file = download(
          directory, FILE_TEMPLATE.format(split=split_name)
      )
      dataset = tf.data.TextLineDataset(amat_file)
      str_to_arr = lambda string: np.array(
          [c == b"1" for c in string.split()]
      )
  
      def _parser(s):
          booltensor = tf.compat.v1.py_func(str_to_arr, [s], tf.bool)
          reshaped = tf.reshape(booltensor, [28, 28, 1])
          return tf.cast(reshaped, dtype=tf.float32), tf.constant(
              0, tf.int32
          )
  
      return dataset.map(_parser)
  
imports: import functools
  import os
  import time
  from absl import flags
  from matplotlib import cm
  from matplotlib import figure
  from matplotlib.backends import backend_agg
  import numpy
  from six.moves import urllib
  import tensorflow.compat.v1
  from tensorflow_probability import distributions
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow.contrib.learn.python.learn.datasets import mnist
  from tensorflow.python.training import moving_averages
label_desc: Use image node_id 8 for calling a global function with example usage: load_bernoulli_mnist_dataset(directory, split_name) and returns: dataset, tf,  tf