code: def fully_connected(
      incoming,
      n_units,
      activation="linear",
      bias=True,
      weights_init="truncated_normal",
      bias_init="zeros",
      regularizer=None,
      weight_decay=0.001,
      trainable=True,
      restore=True,
      reuse=False,
      scope=None,
      name="FullyConnected",
  ):
      """Fully Connected.
  
      A fully connected layer.
  
      Input:
          (2+)-D Tensor [samples, input dim]. If not 2D, input will be flatten.
  
      Output:
          2D Tensor [samples, n_units].
  
      Arguments:
          incoming: `Tensor`. Incoming (2+)D Tensor.
          n_units: `int`, number of units for this layer.
          activation: `str` (name) or `function` (returning a `Tensor`).
              Activation applied to this layer (see tflearn.activations).
              Default: 'linear'.
          bias: `bool`. If True, a bias is used.
          weights_init: `str` (name) or `Tensor`. Weights initialization.
              (see tflearn.initializations) Default: 'truncated_normal'.
          bias_init: `str` (name) or `Tensor`. Bias initialization.
              (see tflearn.initializations) Default: 'zeros'.
          regularizer: `str` (name) or `Tensor`. Add a regularizer to this
              layer weights (see tflearn.regularizers). Default: None.
          weight_decay: `float`. Regularizer decay parameter. Default: 0.001.
          trainable: `bool`. If True, weights will be trainable.
          restore: `bool`. If True, this layer weights will be restored when
              loading a model.
          reuse: `bool`. If True and 'scope' is provided, this layer variables
              will be reused (shared).
          scope: `str`. Define this layer scope (optional). A scope can be
              used to share variables between layers. Note that scope will
              override name.
          name: A name for this layer (optional). Default: 'FullyConnected'.
  
      Attributes:
          scope: `Scope`. This layer scope.
          W: `Tensor`. Variable representing units weights.
          b: `Tensor`. Variable representing biases.
  
      """
      input_shape = utils.get_incoming_shape(incoming)
      assert (
          len(input_shape) > 1
      ), "Incoming Tensor shape must be at least 2-D"
      n_inputs = int(np.prod(input_shape[1:]))
  
      with tf.variable_scope(
          scope, default_name=name, values=[incoming], reuse=reuse
      ) as scope:
          name = scope.name
  
          W_init = weights_init
          filter_size = [n_inputs, n_units]
          if isinstance(weights_init, str):
              W_init = initializations.get(weights_init)()
          elif type(W_init) in [tf.Tensor, np.ndarray, list]:
              filter_size = None
          W_regul = None
          if regularizer is not None:
              W_regul = lambda x: regularizers.get(regularizer)(
                  x, weight_decay
              )
          W = va.variable(
              "W",
              shape=filter_size,
              regularizer=W_regul,
              initializer=W_init,
              trainable=trainable,
              restore=restore,
          )
          tf.add_to_collection(
              tf.GraphKeys.LAYER_VARIABLES + "/" + name, W
          )
  
          b = None
          if bias:
              b_shape = [n_units]
              if isinstance(bias_init, str):
                  bias_init = initializations.get(bias_init)()
              elif type(bias_init) in [tf.Tensor, np.ndarray, list]:
                  b_shape = None
              if isinstance(bias_init, str):
                  bias_init = initializations.get(bias_init)()
              b = va.variable(
                  "b",
                  shape=b_shape,
                  initializer=bias_init,
                  trainable=trainable,
                  restore=restore,
              )
              tf.add_to_collection(
                  tf.GraphKeys.LAYER_VARIABLES + "/" + name, b
              )
  
          inference = incoming
          # If input is not 2d, flatten it.
          if len(input_shape) > 2:
              inference = tf.reshape(inference, [-1, n_inputs])
  
          inference = tf.matmul(inference, W)
          if b is not None:
              inference = tf.nn.bias_add(inference, b)
          if activation:
              if isinstance(activation, str):
                  inference = activations.get(activation)(inference)
              elif hasattr(activation, "__call__"):
                  inference = activation(inference)
              else:
                  raise ValueError("Invalid Activation.")
  
          # Track activations.
          tf.add_to_collection(tf.GraphKeys.ACTIVATIONS, inference)
  
      # Add attributes to Tensor to easy access weights.
      inference.scope = scope
      inference.W = W
      inference.b = b
  
      # Track output tensor.
      tf.add_to_collection(
          tf.GraphKeys.LAYER_TENSOR + "/" + name, inference
      )
  
      return inference
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  import tensorflow.compat.v1
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import standard_ops
  import tflearn
  from tflearn import utils
  from tflearn import variables
  from tflearn import activations
  from tflearn import initializations
  from tflearn import regularizers
label_desc: Use image node_id 2 for calling a global function with example usage: fully_connected(incoming, n_units, activation, bias, weights_init, bias_init, regularizer, weight_decay, trainable, restore, reuse, scope, name) and returns: inference