code: def factor_dense(
      model,
      projection_function=None,
      filter_function=None,
      factor_function=None,
  ):
      """
      Reduce the size of a dense model using the provided factor_function
      and the projection_function. filter_function is used to select dense
      layers to apply the reduction. If no factor_function is specified,
      use svd decomposition.
  
      Args:
          model               : dense model.
          projection_function : determin the new size of the dense model. It can
                                be based on the shape of the weight matrix or
                                other heuristics.
                                factor_function can choose to ignore the value k.
          filter_function     : filter layers in the model to apply the factorization
          factor_function     : factor the dense model (e.g. svd)
  
      Returns:
          a model that is factored and reduced in size.
      """
      if factor_function == None and projection_function == None:
          raise ValueError(
              "Dense: default factor function (svd) requires a projection_function."
          )
  
      dense_filter = (
          lambda x: type(x) == cntk.Function
          and x.op_name == "Dense"
          and x.is_block
          and (filter_function(x) if filter_function else True)
      )
  
      def dense_converter(model):
          W, b = model.W.value, model.b.value
  
          ht, wdth = W.shape
          # k is the rank of the output matrices. If a projection function is
          # provided, then use it, otherwise assign min of two dimensions of
          # W to k.
          k = (
              projection_function(W)
              if projection_function
              else min(ht, wdth)
          )
          W1, W2 = (
              factor_function(W, k)
              if factor_function
              else svd_subprojection(W, k)
          )
  
          Ws = {"W1": W1, "W2": W2}
          dfl = dense_factored(
              (int(k), int(wdth)),
              init=Ws,
              activation=None,
              init_bias=b,
              name="DenseFactored",
          )(model.inputs[2])
          return dfl
  
      return cntk.misc.convert(model, dense_filter, dense_converter)
  
file_path: CNTK/bindings/python/cntk/contrib/netopt/factorization.py
imports: import cntk
  from cntk.ops.functions import BlockFunction
  from cntk.variables import Parameter
  from cntk.ops import times
  from cntk.internal import _as_tuple
  from cntk.layers.blocks import _initializer_for, _INFERRED, identity
  from cntk.layers.blocks import UntestedBranchError
  from cntk.default_options import is_default_override
  from cntk.default_options import get_default_override, default_override_or
label_desc: Use image node_id 2 for calling a global function with example usage: factor_dense(model, projection_function, filter_function, factor_function) and returns: cntk, dfl