code: def preprocess_mnist(sc, options):
      """
      Preprocess mnist dataset.
      Normalize and transform into Sample of RDDs.
      """
      train_data = (
          get_mnist(sc, "train", options.dataPath)
          .map(
              lambda rec_tuple: (
                  normalizer(
                      rec_tuple[0], mnist.TRAIN_MEAN, mnist.TRAIN_STD
                  ),
                  rec_tuple[1],
              )
          )
          .map(lambda t: Sample.from_ndarray(t[0], t[1]))
      )
      test_data = (
          get_mnist(sc, "test", options.dataPath)
          .map(
              lambda rec_tuple: (
                  normalizer(
                      rec_tuple[0], mnist.TEST_MEAN, mnist.TEST_STD
                  ),
                  rec_tuple[1],
              )
          )
          .map(lambda t: Sample.from_ndarray(t[0], t[1]))
      )
      return train_data, test_data
  
imports: from bigdl.dllib.feature.dataset import mnist
  from bigdl.dllib.feature.dataset.transformer import *
  from bigdl.dllib.optim.optimizer import *
label_desc: Use image node_id 2 for calling a global function with example usage: preprocess_mnist(sc, options) and returns: train_data,  test_data