class_docstr: A dataset for MNIST.
class_docstr_tok: ["A","dataset","for","MNIST","."]
docstr: Return the next `batch_size` examples from this data set.
docstr_tok: ["Return","the","next","`","batch_size","`","examples","from","this","data","set","."]
code: def next_batch(self, batch_size, fake_data=False, shuffle=True):
      """Return the next `batch_size` examples from this data set."""
      if fake_data:
          fake_image = [1] * 784
          if self.one_hot:
              fake_label = [1] + [0] * 9
          else:
              fake_label = 0
          return [fake_image for _ in range(batch_size)], [
              fake_label for _ in range(batch_size)
          ]
      start = self._index_in_epoch
      # Shuffle for the first epoch
      if self._epochs_completed == 0 and start == 0 and shuffle:
          perm0 = np.arange(self._num_examples)
          np.random.shuffle(perm0)
          self._images = self.images[perm0]
          self._labels = self.labels[perm0]
      # Go to the next epoch
      if start + batch_size > self._num_examples:
          # Finished epoch
          self._epochs_completed += 1
          # Get the rest examples in this epoch
          rest_num_examples = self._num_examples - start
          images_rest_part = self._images[start : self._num_examples]
          labels_rest_part = self._labels[start : self._num_examples]
          # Shuffle the data
          if shuffle:
              perm = np.arange(self._num_examples)
              np.random.shuffle(perm)
              self._images = self.images[perm]
              self._labels = self.labels[perm]
          # Start next epoch
          start = 0
          self._index_in_epoch = batch_size - rest_num_examples
          end = self._index_in_epoch
          images_new_part = self._images[start:end]
          labels_new_part = self._labels[start:end]
          return np.concatenate(
              (images_rest_part, images_new_part), axis=0
          ), np.concatenate((labels_rest_part, labels_new_part), axis=0)
      else:
          self._index_in_epoch += batch_size
          end = self._index_in_epoch
          return self._images[start:end], self._labels[start:end]
  
file_path: magenta/magenta/models/latent_transfer/local_mnist.py
imports: import gzip
  import os
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling the DataSet obj's underlying member method code with example usage: obj.next_batch(batch_size, fake_data, shuffle) and returns: unknown,  unknown, np,  np, self,  self