code: def create_image_mb_source(
      map_file, mean_file, train, total_number_of_samples
  ):
      if not os.path.exists(map_file) or not os.path.exists(mean_file):
          raise RuntimeError(
              "File '%s' or '%s' does not exist."
              % (map_file, mean_file)
          )
  
      # transformation pipeline for the features has jitter/crop only when training
      transforms = []
      if train:
          transforms += [
              xforms.crop(
                  crop_type="randomarea",
                  area_ratio=(0.08, 1.0),
                  aspect_ratio=(0.75, 1.3333),
                  jitter_type="uniratio",
              ),  # train uses jitter
              xforms.color(
                  brightness_radius=0.4,
                  contrast_radius=0.4,
                  saturation_radius=0.4,
              ),
          ]
      else:
          transforms += [
              C.io.transforms.crop(
                  crop_type="center", side_ratio=0.875
              )  # test has no jitter
          ]
  
      transforms += [
          xforms.scale(
              width=image_width,
              height=image_height,
              channels=num_channels,
              interpolations="cubic",
          ),
          xforms.mean(mean_file),
      ]
  
      # deserializer
      return C.io.MinibatchSource(
          C.io.ImageDeserializer(
              map_file,
              C.io.StreamDefs(
                  features=C.io.StreamDef(
                      field="image", transforms=transforms
                  ),  # 1st col in mapfile referred to as 'image'
                  labels=C.io.StreamDef(
                      field="label", shape=num_classes
                  ),
              ),
          ),  # and second as 'label'
          randomize=train,
          max_samples=total_number_of_samples,
          multithreaded_deserializer=True,
      )
  
file_path: CNTK/Examples/Image/Classification/ResNet/Python/TrainResNet_ImageNet_Distributed.py
imports: from __future__ import print_function
  import os
  import argparse
  import cntk
  import numpy
  from cntk import input, cross_entropy_with_softmax, classification_error, Trainer, cntk_py
  from cntk import data_parallel_distributed_learner, block_momentum_distributed_learner, Communicator
  from cntk.learners import nesterov, learning_rate_schedule, momentum_schedule, UnitType
  from cntk.device import try_set_default_device, gpu
  from cntk.train.training_session import *
  from cntk.debugging import *
  from cntk.logging import *
  from resnet_models import *
  import cntk.io.transforms
label_desc: Use image node_id 1 for calling a global function with example usage: create_image_mb_source(map_file, mean_file, train, total_number_of_samples) and returns: C