code: def _preprocess_mnist(
      raw, withlabel, ndim, scale, image_dtype, label_dtype, rgb_format
  ):
      images = raw["x"][-100:]
      if ndim == 2:
          images = images.reshape(-1, 28, 28)
      elif ndim == 3:
          images = images.reshape(-1, 1, 28, 28)
          if rgb_format:
              images = np.broadcast_to(
                  images, (len(images), 3) + images.shape[2:]
              )
      elif ndim != 1:
          raise ValueError("invalid ndim for MNIST dataset")
      images = images.astype(image_dtype)
      images *= scale / 255.0
  
      if withlabel:
          labels = raw["y"][-100:].astype(label_dtype)
          return tuple_dataset.TupleDataset(images, labels)
      return images
  
file_path: sagemaker-python-sdk/tests/data/chainer_mnist/distributed_mnist.py
imports: from __future__ import print_function
  import argparse
  import logging
  import os
  import chainer
  from chainer import serializers, training
  from chainer.datasets import tuple_dataset
  import chainer.functions
  import chainer.links
  from chainer.training import extensions
  import chainermn
  import numpy
  import sagemaker_containers
label_desc: Use image node_id 1 for calling a global function with example usage: _preprocess_mnist(raw, withlabel, ndim, scale, image_dtype, label_dtype, rgb_format) and returns: images, tuple_dataset