code: def MultiLayerFC(
      in_tensor,
      dims,
      subgraph,
      relu_in=False,
      relu_mid=True,
      relu_out=False,
      dropout_in=None,
      dropout_mid=None,
      dropout_out=None,
      bias_in=True,
      bias_mid=True,
      bias_out=True,
      batch_norm=False,
      train=True,
      l2_reg=None,
      scope=None,
  ):
      with tf.variable_scope(
          scope, default_name="multilayerfc", reuse=tf.AUTO_REUSE
      ) as var_scope:
          _in = in_tensor
  
          if relu_in:
              _in = tf.nn.relu(_in)
  
          if dropout_in is not None:
              _in = tf.nn.dropout(
                  _in, 1 - dropout_in
              )  # Tensorflow uses keep_prob
  
          for index, _out_dim in enumerate(dims):
              mat = tf.get_variable(
                  "FC_" + "_" + str(index),
                  shape=[_in.shape[1], _out_dim],
                  trainable=True,
                  initializer=tf.contrib.layers.xavier_initializer(),
              )
              if index == 0:
                  add_bias = bias_in
              elif index == len(dims) - 1:
                  add_bias = bias_out
              else:
                  add_bias = bias_mid
  
              if add_bias:
                  _bias = tf.get_variable(
                      "bias_" + "_" + str(index),
                      shape=[_out_dim],
                      trainable=True,
                      initializer=tf.constant_initializer(
                          value=0.0, dtype=tf.float32
                      ),
                  )
                  _out = tf.matmul(_in, mat) + _bias
              else:
                  _out = tf.matmul(_in, mat)
  
              if index < len(dims) - 1:
                  if relu_mid:
                      _out = tf.nn.relu(_out)
                  if dropout_mid is not None:
                      _out = tf.nn.dropout(_out, 1 - dropout_mid)
              elif index == len(dims) - 1:
                  if relu_out:
                      _out = tf.nn.relu(_out)
                  if dropout_out is not None:
                      _out = tf.nn.dropout(_out, 1 - dropout_out)
              if batch_norm:
                  _out = tf.contrib.layers.batch_norm(
                      _out,
                      fused=True,
                      decay=0.95,
                      center=True,
                      scale=True,
                      is_training=train,
                      scope="bn_" + str(index),
                      updates_collections=None,
                  )
              _in = _out
  
          if l2_reg is not None:
              for var in tf.get_collection(
                  tf.GraphKeys.TRAINABLE_VARIABLES, scope=var_scope.name
              ):
                  subgraph.register_global_loss(
                      l2_reg * tf.nn.l2_loss(var)
                  )
  
          return _out
  
label_desc: Use image node_id 1 for calling a global function with example usage: MultiLayerFC(in_tensor, dims, subgraph, relu_in, relu_mid, relu_out, dropout_in, dropout_mid, dropout_out, bias_in, bias_mid, bias_out, batch_norm, train, l2_reg, scope) and returns: _out