code: def mnist_common_generator(
      tmp_dir,
      training,
      how_many,
      data_filename,
      label_filename,
      start_from=0,
  ):
      """Image generator for MNIST.
  
      Args:
        tmp_dir: path to temporary storage directory.
        training: a Boolean; if true, we use the train set, otherwise the test set.
        how_many: how many images and labels to generate.
        data_filename: file that contains features data.
        label_filename: file that contains labels.
        start_from: from which image to start.
  
      Returns:
        An instance of image_generator that produces MNIST images.
      """
      data_path = os.path.join(tmp_dir, data_filename)
      labels_path = os.path.join(tmp_dir, label_filename)
      images = _extract_mnist_images(
          data_path, 60000 if training else 10000
      )
      labels = _extract_mnist_labels(
          labels_path, 60000 if training else 10000
      )
      # Shuffle the data to make sure classes are well distributed.
      data = list(zip(images, labels))
      random.shuffle(data)
      images, labels = list(zip(*data))
      return image_utils.image_generator(
          images[start_from : start_from + how_many],
          labels[start_from : start_from + how_many],
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gzip
  import os
  import random
  import numpy
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import image_utils
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 4 for calling a global function with example usage: mnist_common_generator(tmp_dir, training, how_many, data_filename, label_filename, start_from) and returns: image_utils