class_docstr: Produces [image, label] in MNIST dataset,
  image is 28x28 in the range [0,1], label is an int.
class_docstr_tok: ["Produces","[","image",",","label","]","in","MNIST","dataset",",","image","is","28x28","in","the","range","[","0,1","]",",","label","is","an","int","."]
docstr: Args:
      train_or_test (str): either 'train' or 'test'
      shuffle (bool): shuffle the dataset
docstr_tok: ["Args",":","train_or_test","(","str",")",":","either","'train","'","or","'test'","shuffle","(","bool",")",":","shuffle","the","dataset"]
code: def __init__(self, train_or_test, shuffle=True, dir=None):
      """
      Args:
          train_or_test (str): either 'train' or 'test'
          shuffle (bool): shuffle the dataset
      """
      if dir is None:
          dir = get_dataset_path(self._DIR_NAME)
      assert train_or_test in ["train", "test"]
      self.train_or_test = train_or_test
      self.shuffle = shuffle
  
      def get_images_and_labels(image_file, label_file):
          f = maybe_download(self._SOURCE_URL + image_file, dir)
          images = extract_images(f)
          f = maybe_download(self._SOURCE_URL + label_file, dir)
          labels = extract_labels(f)
          assert images.shape[0] == labels.shape[0]
          return images, labels
  
      if self.train_or_test == "train":
          self.images, self.labels = get_images_and_labels(
              "train-images-idx3-ubyte.gz", "train-labels-idx1-ubyte.gz"
          )
      else:
          self.images, self.labels = get_images_and_labels(
              "t10k-images-idx3-ubyte.gz", "t10k-labels-idx1-ubyte.gz"
          )
  
file_path: tensorpack/tensorpack/dataflow/dataset/mnist.py
imports: import gzip
  import numpy
  import os
  from ...utils import logger
  from ...utils.fs import download, get_dataset_path
  from ..base import RNGDataFlow
label_desc: Use image node_id 1 to create a new Mnist object from inherited base classes: RNGDataFlow with example: obj = Mnist(train_or_test, shuffle, dir)