code: def adjust_lr_callback(
      index, average_error, cv_num_samples, cv_num_minibatches
  ):
      global prev_metric
      if (
          prev_metric - average_error
      ) / prev_metric < 0.05:  # relative gain must reduce metric by at least 5% rel
          learner.reset_learning_rate(
              C.learning_parameter_schedule_per_sample(
                  learner.learning_rate() / 2
              )
          )
          if learner.learning_rate() < lr_per_sample / (
              2**7 - 0.1
          ):  # we are done after the 6-th LR cut
              print(
                  "Learning rate {} too small. Training complete.".format(
                      learner.learning_rate()
                  )
              )
              return False  # means we are done
          print(
              "Improvement of metric from {:.3f} to {:.3f} insufficient. Halving learning rate to {}.".format(
                  prev_metric, average_error, learner.learning_rate()
              )
          )
      prev_metric = average_error
      return True
  
imports: from __future__ import print_function
  import os
  import cntk
  import numpy
  import scipy.sparse
label_desc: Use image node_id 2 for calling a global function with example usage: adjust_lr_callback(index, average_error, cv_num_samples, cv_num_minibatches) and returns: True, False