code: def create_trainer(
      network,
      epoch_size,
      num_epochs,
      minibatch_size,
      num_quantization_bits,
      progress_printer,
  ):
      # CNTK weights new gradient by (1-momentum) for unit gain,
      # thus we divide Caffe's learning rate by (1-momentum)
      initial_learning_rate = 2.0  # equal to 0.2 in caffe
      initial_learning_rate *= minibatch_size / 128
      learn_rate_adjust_interval = 2
      learn_rate_decrease_factor = 0.94
  
      # Set learning parameters
      lr_per_mb = []
      learning_rate = initial_learning_rate
      for i in range(0, num_epochs, learn_rate_adjust_interval):
          lr_per_mb.extend([learning_rate] * learn_rate_adjust_interval)
          learning_rate *= learn_rate_decrease_factor
  
      lr_schedule = learning_parameter_schedule(
          lr_per_mb, epoch_size=epoch_size
      )
      mm_schedule = momentum_schedule(0.9)
      l2_reg_weight = 0.0001  # CNTK L2 regularization is per sample, thus same as Caffe
  
      # Create learner
      local_learner = momentum_sgd(
          network["output"].parameters,
          lr_schedule,
          mm_schedule,
          l2_regularization_weight=l2_reg_weight,
      )
      parameter_learner = data_parallel_distributed_learner(
          local_learner,
          num_quantization_bits=num_quantization_bits,
          distributed_after=0,
      )
  
      # Create trainer
      return Trainer(
          network["output"],
          (network["ce"], network["pe"]),
          parameter_learner,
          progress_printer,
      )
  
file_path: CNTK/Examples/Image/Classification/GoogLeNet/BN-Inception/Python/BN_Inception_CIFAR10_Distributed.py
imports: from __future__ import print_function
  from __future__ import division
  import os
  import math
  import argparse
  import numpy
  import cntk
  import _cntk_py
  import cntk.io.transforms
  from cntk.debugging import start_profiler, stop_profiler
  from cntk.learners import learning_parameter_schedule, momentum_schedule, momentum_sgd
  from cntk.logging import ProgressPrinter, log_number_of_parameters
  from cntk.ops import input
  from cntk.io import ImageDeserializer, MinibatchSource, StreamDef, StreamDefs, FULL_DATA_SWEEP
  from cntk.train.distributed import data_parallel_distributed_learner, Communicator
  from cntk.train import training_session, CheckpointConfig, TestConfig, Trainer
  from BN_Inception_CIFAR10 import create_image_mb_source, create_bn_inception
label_desc: Use image node_id 1 for calling a global function with example usage: create_trainer(network, epoch_size, num_epochs, minibatch_size, num_quantization_bits, progress_printer) and returns: Trainer