code: def ffnet(learner, trainer=None):
      inputs = 5
      outputs = 3
      layers = 2
      hidden_dimension = 3
  
      if trainer is None:
          # input variables denoting the features and label data
          features = C.input_variable((inputs), np.float32)
          label = C.input_variable((outputs), np.float32)
  
          # Instantiate the feedforward classification model
          my_model = Sequential(
              [
                  Dense(
                      hidden_dimension,
                      activation=C.sigmoid,
                      init=C.glorot_uniform(seed=98052),
                  ),
                  Dense(outputs, init=C.glorot_uniform(seed=98052)),
              ]
          )
          z = my_model(features)
  
          ce = C.cross_entropy_with_softmax(z, label)
          pe = C.classification_error(z, label)
  
          # Instantiate the trainer object to drive the model training
          progress_printer = ProgressPrinter(0)
          trainer = C.Trainer(
              z, (ce, pe), [learner(z.parameters)], [progress_printer]
          )
      else:
          features = trainer.loss_function.arguments[0]
          label = trainer.loss_function.arguments[1]
  
      # Get minibatches of training data and perform model training
      minibatch_size = 25
      num_minibatches_to_train = 100
  
      aggregate_loss = 0.0
      for i in range(num_minibatches_to_train):
          train_features, labels = generate_random_data(
              minibatch_size, inputs, outputs
          )
          # Specify the mapping of input variables in the model to actual minibatch data to be trained with
          trainer.train_minibatch(
              {features: train_features, label: labels}
          )
          sample_count = trainer.previous_minibatch_sample_count
          aggregate_loss += (
              trainer.previous_minibatch_loss_average * sample_count
          )
  
      last_avg_error = (
          aggregate_loss / trainer.total_number_of_samples_seen
      )
  
      test_features, test_labels = generate_random_data(
          minibatch_size, inputs, outputs
      )
      avg_error = trainer.test_minibatch(
          {features: test_features, label: test_labels}
      )
      print(" error rate on an unseen minibatch: {}".format(avg_error))
      return last_avg_error, avg_error, trainer
  
imports: from __future__ import division, print_function
  import numpy
  import cntk
  from cntk import parameter
  import pytest
  import sys
  import itertools
  from cntk.logging import ProgressPrinter
  from cntk.learners import sgd, learning_rate_schedule, learning_parameter_schedule, UnitType, universal
  from cntk.layers import Dense, Sequential
label_desc: Use image node_id 16 for calling a global function with example usage: ffnet(learner, trainer) and returns: last_avg_error,  avg_error,  trainer