class_docstr: Setup CNTK ops with given parameters
class_docstr_tok: ["Setup","CNTK","ops","with","given","parameters"]
docstr:  Setup dense op with given parameters
  
  Args:
      cntk_layer (:class:`~cntk.contrib.crosstalkcaffe.unimodel.cntkmodel.CntkLayersDefinition`):
          the layer definition of dense op
      inputs (list): a list contains all :class:`~cntk.ops.functions.Function` or
          :class:`~cntk.input`
  
  Return:
      :func:`~cntk.ops.functions.Function`: instaced cntk dense op
docstr_tok: ["Setup","dense","op","with","given","parameters","Args",":","cntk_layer","(",":","class",":","`","~cntk.contrib.crosstalkcaffe.unimodel.cntkmodel.CntkLayersDefinition","`",")",":","the","layer","definition","of","dense","op","inputs","(","list",")",":","a","list","contains","all",":","class",":","`","~cntk.ops.functions.Function","`","or",":","class",":","`","~cntk.input","`","Return",":",":","func",":","`","~cntk.ops.functions.Function","`",":","instaced","cntk","dense","op"]
code: def dense(cntk_layer, inputs):
      """
       Setup dense op with given parameters
  
      Args:
          cntk_layer (:class:`~cntk.contrib.crosstalkcaffe.unimodel.cntkmodel.CntkLayersDefinition`):
              the layer definition of dense op
          inputs (list): a list contains all :class:`~cntk.ops.functions.Function` or
              :class:`~cntk.input`
  
      Return:
          :func:`~cntk.ops.functions.Function`: instaced cntk dense op
      """
      sanitize_input = internal.sanitize_input(inputs[0])
      input_channel = sanitize_input.shape
      output_channel = cntk_layer.parameters.num_output
  
      flattened_channel = reduce(mul, list(input_channel))
      scale_shape = input_channel + (output_channel,)
      bias_shape = (output_channel,)
  
      if cntk_layer.parameter_tensor:
          if len(cntk_layer.parameter_tensor) != 2:
              raise AssertionError(
                  "dense layer layer receives two inputs (scale/bias)"
              )
          scale_tensor = cntk_layer.parameter_tensor[0]
          bias_tensor = cntk_layer.parameter_tensor[1]
          scale_init = np.asarray(scale_tensor.data, np.float32)
          if cntk_layer.parameters.transpose:
              scale_init = np.reshape(
                  scale_init, (output_channel, flattened_channel)
              )
              scale_init = np.transpose(scale_init).copy()
              scale_init = np.reshape(scale_init, scale_shape)
          else:
              scale_init = np.reshape(scale_init, scale_shape)
          bias_init = np.asarray(bias_tensor.data, np.float32)
      return BlockApiSetup.linear(
          bias_shape,
          scale_shape,
          scale_init,
          bias_init,
          cntk_layer.op_name,
      )(sanitize_input)
  
imports: from operator import mul
  from functools import reduce
  import numpy
  import cntk
  import cntk.io.transforms
  from cntk import ops, io, learners, internal
  from cntk import Trainer
  from cntk.layers.blocks import BlockFunction
label_desc: Use image node_id 5 for calling the ApiSetup obj's underlying member method code with example usage: obj.dense(cntk_layer, inputs) and returns: BlockApiSetup