code: def train_model(
      image_input,
      roi_input,
      dims_input,
      loss,
      pred_error,
      lr_per_sample,
      mm_schedule,
      l2_reg_weight,
      epochs_to_train,
      cfg,
      rpn_rois_input=None,
      buffered_rpn_proposals=None,
  ):
      if isinstance(loss, cntk.Variable):
          loss = combine([loss])
  
      params = loss.parameters
      biases = [p for p in params if ".b" in p.name or "b" == p.name]
      others = [p for p in params if not p in biases]
      bias_lr_mult = cfg["CNTK"].BIAS_LR_MULT
  
      if cfg["CNTK"].DEBUG_OUTPUT:
          print("biases")
          for p in biases:
              print(p)
          print("others")
          for p in others:
              print(p)
          print("bias_lr_mult: {}".format(bias_lr_mult))
  
      # Instantiate the learners and the trainer object
      lr_schedule = learning_parameter_schedule_per_sample(
          lr_per_sample
      )
      learner = momentum_sgd(
          others,
          lr_schedule,
          mm_schedule,
          l2_regularization_weight=l2_reg_weight,
          unit_gain=False,
          use_mean_gradient=True,
      )
  
      bias_lr_per_sample = [v * bias_lr_mult for v in lr_per_sample]
      bias_lr_schedule = learning_parameter_schedule_per_sample(
          bias_lr_per_sample
      )
      bias_learner = momentum_sgd(
          biases,
          bias_lr_schedule,
          mm_schedule,
          l2_regularization_weight=l2_reg_weight,
          unit_gain=False,
          use_mean_gradient=True,
      )
      trainer = Trainer(
          None, (loss, pred_error), [learner, bias_learner]
      )
  
      # Get minibatches of images and perform model training
      print("Training model for %s epochs." % epochs_to_train)
      log_number_of_parameters(loss)
  
      # Create the minibatch source
      if buffered_rpn_proposals is not None:
          proposal_provider = ProposalProvider.fromlist(
              buffered_rpn_proposals, requires_scaling=False
          )
      else:
          proposal_provider = None
  
      od_minibatch_source = ObjectDetectionMinibatchSource(
          cfg["DATA"].TRAIN_MAP_FILE,
          cfg["DATA"].TRAIN_ROI_FILE,
          num_classes=cfg["DATA"].NUM_CLASSES,
          max_annotations_per_image=cfg.INPUT_ROIS_PER_IMAGE,
          pad_width=cfg.IMAGE_WIDTH,
          pad_height=cfg.IMAGE_HEIGHT,
          pad_value=cfg["MODEL"].IMG_PAD_COLOR,
          randomize=True,
          use_flipping=cfg["TRAIN"].USE_FLIPPED,
          max_images=cfg["DATA"].NUM_TRAIN_IMAGES,
          proposal_provider=proposal_provider,
      )
  
      # define mapping from reader streams to network inputs
      input_map = {
          od_minibatch_source.image_si: image_input,
          od_minibatch_source.roi_si: roi_input,
      }
      if buffered_rpn_proposals is not None:
          input_map[od_minibatch_source.proposals_si] = rpn_rois_input
      else:
          input_map[od_minibatch_source.dims_si] = dims_input
  
      progress_printer = ProgressPrinter(
          tag="Training", num_epochs=epochs_to_train, gen_heartbeat=True
      )
      for epoch in range(epochs_to_train):  # loop over epochs
          sample_count = 0
          while (
              sample_count < cfg["DATA"].NUM_TRAIN_IMAGES
          ):  # loop over minibatches in the epoch
              data = od_minibatch_source.next_minibatch(
                  min(
                      cfg.MB_SIZE,
                      cfg["DATA"].NUM_TRAIN_IMAGES - sample_count,
                  ),
                  input_map=input_map,
              )
              trainer.train_minibatch(data)  # update model with it
              sample_count += (
                  trainer.previous_minibatch_sample_count
              )  # count samples processed so far
              progress_printer.update_with_trainer(
                  trainer, with_metric=True
              )  # log progress
              if sample_count % 100 == 0:
                  print("Processed {} samples".format(sample_count))
  
          progress_printer.epoch_summary(with_metric=True)
  
imports: from __future__ import print_function
  import numpy
  import os, sys
  import argparse
  import easydict
  import cntk
  from cntk import Trainer, load_model, Axis, input_variable, parameter, times, combine, softmax, roipooling, plus, element_times, CloneMethod, alias, Communicator, reduce_sum
  from cntk.core import Value
  from cntk.io import MinibatchData
  from cntk.initializer import normal
  from cntk.layers import placeholder, Constant, Sequential
  from cntk.learners import momentum_sgd, learning_parameter_schedule_per_sample, momentum_schedule
  from cntk.logging import log_number_of_parameters, ProgressPrinter
  from cntk.logging.graph import find_by_name, plot
  from cntk.losses import cross_entropy_with_softmax
  from cntk.metrics import classification_error
  from _cntk_py import force_deterministic_algorithms
  from utils.rpn.rpn_helpers import create_rpn, create_proposal_target_layer, create_proposal_layer
  from utils.annotations.annotations_helper import parse_class_map_file
  from utils.od_mb_source import ObjectDetectionMinibatchSource
  from utils.proposal_helpers import ProposalProvider
  from FastRCNN.FastRCNN_train import clone_model, clone_conv_layers, create_fast_rcnn_predictor, create_detection_losses
label_desc: Use image node_id 10 for calling a global function with example usage: train_model(image_input, roi_input, dims_input, loss, pred_error, lr_per_sample, mm_schedule, l2_reg_weight, epochs_to_train, cfg, rpn_rois_input, buffered_rpn_proposals) without return types