code: def train_and_test(
      network,
      trainer,
      train_source,
      test_source,
      minibatch_size,
      epoch_size,
      restore=True,
      profiling=False,
  ):
      # define mapping from intput streams to network inputs
      input_map = {
          network["feature"]: train_source.streams.features,
          network["label"]: train_source.streams.labels,
      }
  
      if profiling:
          start_profiler(sync_gpu=True)
  
      training_session(
          trainer=trainer,
          mb_source=train_source,
          mb_size=minibatch_size,
          model_inputs_to_streams=input_map,
          progress_frequency=epoch_size,
          checkpoint_config=CheckpointConfig(
              frequency=epoch_size,
              filename=os.path.join(model_path, model_name),
              restore=restore,
          ),
          test_config=TestConfig(test_source, minibatch_size),
      ).train()
  
      if profiling:
          stop_profiler()
  
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 4 for calling a global function with example usage: train_and_test(network, trainer, train_source, test_source, minibatch_size, epoch_size, restore, profiling) without return types