original_docstring: Split MNIST dataset by labels.
  
          Args:
                  nb_splits: numer of splits
                  mode: whether to use train or testing data
  
          Returns:
              List of (X, y) tuples representing each dataset
      
docstring: Split MNIST dataset by labels.
docstring_tokens: Split MNIST dataset by labels .
code: def construct_randomly_split_mnist(nb_splits=10, mode='train'):
      """Split MNIST dataset by labels.
  
          Args:
                  nb_splits: numer of splits
                  mode: whether to use train or testing data
  
          Returns:
              List of (X, y) tuples representing each dataset
      """
      # Load MNIST data and normalize
      nb_classes = 10
      (X_train, y_train), (X_test, y_test) = mnist.load_data()
      X_train = X_train.reshape(-1, 784)
      X_test = X_test.reshape(-1, 784)
      X_train = X_train.astype('float32')
      X_test = X_test.astype('float32')
      X_train /= 255
      X_test /= 255
  
      if mode == 'train':
          X, y = X_train, y_train
      else:
          X, y = X_test, y_test
  
      return split_dataset_randomly(X, y, nb_splits, nb_classes)
code_tokens: def construct_randomly_split_mnist ( nb_splits = 10 , mode = 'train' ) : nb_classes = 10 ( X_train , y_train ) , ( X_test , y_test ) = mnist . load_data ( ) X_train = X_train . reshape ( - 1 , 784 ) X_test = X_test . reshape ( - 1 , 784 ) X_train = X_train . astype ( 'float32' ) X_test = X_test . astype ( 'float32' ) X_train /= 255 X_test /= 255 if mode == 'train' : X , y = X_train , y_train else : X , y = X_test , y_test return split_dataset_randomly ( X , y , nb_splits , nb_classes )
short_docstring: Split MNIST dataset by labels.
short_docstring_tokens: Split MNIST dataset by labels .
comment: """Split MNIST dataset by labels.
  
          Args:
                  nb_splits: numer of splits
                  mode: whether to use train or testing data
  
          Returns:
              List of (X, y) tuples representing each dataset
      """$SEP$# Load MNIST data and normalize