code: def create_trainer(
      network,
      minibatch_size,
      epoch_size,
      num_quantization_bits,
      block_size,
      warm_up,
      progress_printer,
  ):
      lr_per_mb = [1.0] * 30 + [0.1] * 30 + [0.01] * 20 + [0.001]
      l2_reg_weight = 0.0001
  
      # adjust LR with minibatch size
      if minibatch_size != 256:
          for i in range(0, len(lr_per_mb)):
              lr_per_mb[i] *= minibatch_size / 256
  
      # Set learning parameters
      lr_schedule = learning_rate_schedule(
          lr_per_mb, epoch_size=epoch_size, unit=UnitType.minibatch
      )
      mm_schedule = momentum_schedule(0.9)
  
      local_learner = nesterov(
          network["output"].parameters,
          lr_schedule,
          mm_schedule,
          l2_regularization_weight=l2_reg_weight,
      )
  
      # learner object
      if block_size != None and num_quantization_bits != 32:
          raise RuntimeError(
              "Block momentum cannot be used with quantization, please remove quantized_bits option."
          )
  
      if block_size != None:
          learner = block_momentum_distributed_learner(
              local_learner, block_size=block_size
          )
      else:
          learner = data_parallel_distributed_learner(
              local_learner,
              num_quantization_bits=num_quantization_bits,
              distributed_after=warm_up,
          )
  
      return Trainer(
          network["output"],
          (network["ce"], network["errs"]),
          learner,
          progress_printer,
      )
  
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 3 for calling a global function with example usage: create_trainer(network, minibatch_size, epoch_size, num_quantization_bits, block_size, warm_up, progress_printer) and returns: Trainer