code: def test_factor_dense():
      input_dim = 2
      num_output_classes = 2
      hidden_layer_dim = 50
  
      input = C.input_variable(input_dim)
      z = _create_model_dense(
          input, input_dim, hidden_layer_dim, num_output_classes
      )
  
      newz = nc.factor_dense(
          z,
          projection_function=_get_rank_same_size,
          filter_function=_filter,
      )
      newblocks = C.logging.graph.depth_first_search(
          newz,
          lambda x: type(x) == C.Function and x.root_function.is_block,
          depth=0,
      )
  
      assert newblocks[1].op_name == "DenseFactored"
      block_root = C.as_composite(newblocks[1].block_root)
      # no reduction, same size but factored.
      assert block_root.W1.value.shape == (50, 50)
  
      newz = nc.factor_dense(
          z,
          projection_function=_get_rank_reduced_size,
          filter_function=_filter,
      )
      newblocks = C.logging.graph.depth_first_search(
          newz,
          lambda x: type(x) == C.Function and x.root_function.is_block,
          depth=0,
      )
      assert newblocks[1].op_name == "DenseFactored"
      block_root = C.as_composite(newblocks[1].block_root)
      # the reduction has taken place now.
      assert block_root.W1.value.shape == (50, 40)
  
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 7 for calling a global function with example usage: test_factor_dense() without return types