code: def test_factor_dense_for_prediction():
      input_dim = 2
      num_output_classes = 2
      hidden_layer_dim = 50
      num_minibatches_to_train = 2000
      minibatch_size = 25
      learning_rate = 0.5
  
      input = C.input_variable(input_dim)
      label = C.input_variable(num_output_classes)
  
      z = _create_model_dense(
          input, input_dim, hidden_layer_dim, num_output_classes
      )
  
      loss = C.cross_entropy_with_softmax(z, label)
      eval_error = C.classification_error(z, label)
  
      # Instantiate the trainer object to drive the model training
  
      lr_schedule = C.learning_rate_schedule(
          learning_rate, C.UnitType.minibatch
      )
      learner = C.sgd(z.parameters, lr_schedule)
      trainer = C.Trainer(z, (loss, eval_error), [learner])
  
      # Run the trainer and perform model training
      training_progress_output_freq = 20
      plotdata = {"batchsize": [], "loss": [], "error": []}
  
      for i in range(0, int(num_minibatches_to_train)):
          features, labels = _generate_random_data_sample(
              minibatch_size, input_dim, num_output_classes
          )
          # Specify the input variables mapping in the model to actual minibatch data for training
          trainer.train_minibatch({input: features, label: labels})
  
      # generate some data to predict
      features, labels = _generate_random_data_sample(10, 2, 2)
  
      # factor the model.
      newz = nc.factor_dense(
          z,
          projection_function=_get_rank_reduced_size,
          filter_function=_filter,
      )
      original_out = C.softmax(z)
      factored_out = C.softmax(newz)
  
      original_labels_probs = original_out.eval({input: features})
      predicted_label_probs = factored_out.eval({input: features})
  
      original_prediction_percentage = _percentage_match(
          labels, original_labels_probs
      )
  
      # reduced model should have at leat 50% match compared to the original
      # For the test, we reduced the training minibatches, thus the match is lower.
      assert original_prediction_percentage * 0.5 <= _percentage_match(
          labels, predicted_label_probs
      )
  
file_path: CNTK/bindings/python/cntk/contrib/netopt/test/factorization_test.py
imports: import numpy
  import pytest
  import cntk
  import cntk.contrib.netopt.factorization
label_desc: Use image node_id 9 for calling a global function with example usage: test_factor_dense_for_prediction() without return types