code: def _get_norm_mnist(dir, reduced=None, binary=False):
      """Downloads and normalizes mnist"""
      mnist_train = datasets.MNIST(dir, download=True, train=True)
      mnist_test = datasets.MNIST(dir, download=True, train=False)
  
      # compute normalization factors
      data_all = torch.cat([mnist_train.data, mnist_test.data]).float()
      data_mean, data_std = data_all.mean(), data_all.std()
      tensor_mean, tensor_std = data_mean.unsqueeze(
          0
      ), data_std.unsqueeze(0)
  
      # normalize
      mnist_train_norm = transforms.functional.normalize(
          mnist_train.data.float(), tensor_mean, tensor_std
      )
      mnist_test_norm = transforms.functional.normalize(
          mnist_test.data.float(), tensor_mean, tensor_std
      )
  
      # change all nonzero labels to 1 if binary classification required
      if binary:
          mnist_train.targets[mnist_train.targets != 0] = 1
          mnist_test.targets[mnist_test.targets != 0] = 1
  
      # create a reduced dataset if required
      if reduced is not None:
          mnist_norm = (
              mnist_train_norm[:reduced],
              mnist_test_norm[:reduced],
          )
          mnist_labels = (
              mnist_train.targets[:reduced],
              mnist_test.targets[:reduced],
          )
      else:
          mnist_norm = (mnist_train_norm, mnist_test_norm)
          mnist_labels = (mnist_train.targets, mnist_test.targets)
      return mnist_norm, mnist_labels
  
file_path: CrypTen/tutorials/mnist_utils.py
imports: import argparse
  import os
  import torch
  from torchvision import datasets, transforms
label_desc: Use image node_id 1 for calling a global function with example usage: _get_norm_mnist(dir, reduced, binary) and returns: mnist_norm,  mnist_labels