docs: def convert_mnist(directory, output_directory, output_filename=None,
                    dtype=None):
      """Converts the MNIST dataset to HDF5.
  
      Converts the MNIST dataset to an HDF5 dataset compatible with
      :class:`fuel.datasets.MNIST`. The converted dataset is
      saved as 'mnist.hdf5'.
  
      This method assumes the existence of the following files:
      `train-images-idx3-ubyte.gz`, `train-labels-idx1-ubyte.gz`
      `t10k-images-idx3-ubyte.gz`, `t10k-labels-idx1-ubyte.gz`
  
      It assumes the existence of the following files:
  
      * `train-images-idx3-ubyte.gz`
      * `train-labels-idx1-ubyte.gz`
      * `t10k-images-idx3-ubyte.gz`
      * `t10k-labels-idx1-ubyte.gz`
  
      Parameters
      ----------
      directory : str
          Directory in which input files reside.
      output_directory : str
          Directory in which to save the converted dataset.
      output_filename : str, optional
          Name of the saved dataset. Defaults to `None`, in which case a name
          based on `dtype` will be used.
      dtype : str, optional
          Either 'float32', 'float64', or 'bool'. Defaults to `None`,
          in which case images will be returned in their original
          unsigned byte format.
  
      Returns
      -------
      output_paths : tuple of str
          Single-element tuple containing the path to the converted dataset.
  
      """
      if not output_filename:
          if dtype:
              output_filename = 'mnist_{}.hdf5'.format(dtype)
          else:
              output_filename = 'mnist.hdf5'
      output_path = os.path.join(output_directory, output_filename)
      h5file = h5py.File(output_path, mode='w')
  
      train_feat_path = os.path.join(directory, TRAIN_IMAGES)
      train_features = read_mnist_images(train_feat_path, dtype)
      train_lab_path = os.path.join(directory, TRAIN_LABELS)
      train_labels = read_mnist_labels(train_lab_path)
      test_feat_path = os.path.join(directory, TEST_IMAGES)
      test_features = read_mnist_images(test_feat_path, dtype)
      test_lab_path = os.path.join(directory, TEST_LABELS)
      test_labels = read_mnist_labels(test_lab_path)
      data = (('train', 'features', train_features),
              ('train', 'targets', train_labels),
              ('test', 'features', test_features),
              ('test', 'targets', test_labels))
      fill_hdf5_file(h5file, data)
      h5file['features'].dims[0].label = 'batch'
      h5file['features'].dims[1].label = 'channel'
      h5file['features'].dims[2].label = 'height'
      h5file['features'].dims[3].label = 'width'
      h5file['targets'].dims[0].label = 'batch'
      h5file['targets'].dims[1].label = 'index'
  
      h5file.flush()
      h5file.close()
  
      return (output_path,)