code: def single_unit(
      incoming,
      activation="linear",
      bias=True,
      trainable=True,
      restore=True,
      reuse=False,
      scope=None,
      name="Linear",
  ):
      """Single Unit.
  
      A single unit (Linear) Layer.
  
      Input:
          1-D Tensor [samples]. If not 2D, input will be flatten.
  
      Output:
          1-D Tensor [samples].
  
      Arguments:
          incoming: `Tensor`. Incoming Tensor.
          activation: `str` (name) or `function`. Activation applied to this
              layer (see tflearn.activations). Default: 'linear'.
          bias: `bool`. If True, a bias is used.
          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: 'Linear'.
  
      Attributes:
          W: `Tensor`. Variable representing weight.
          b: `Tensor`. Variable representing bias.
  
      """
      input_shape = utils.get_incoming_shape(incoming)
      n_inputs = int(np.prod(input_shape[1:]))
  
      # Build variables and inference.
      with tf.variable_scope(
          scope, default_name=name, values=[incoming], reuse=reuse
      ) as scope:
          name = scope.name
  
          W = va.variable(
              "W",
              shape=[n_inputs],
              initializer=tf.constant_initializer(np.random.randn()),
              trainable=trainable,
              restore=restore,
          )
          tf.add_to_collection(
              tf.GraphKeys.LAYER_VARIABLES + "/" + name, W
          )
  
          b = None
          if bias:
              b = va.variable(
                  "b",
                  shape=[n_inputs],
                  initializer=tf.constant_initializer(
                      np.random.randn()
                  ),
                  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) > 1:
              inference = tf.reshape(inference, [-1])
  
          inference = tf.multiply(inference, W)
          if b is not None:
              inference = tf.add(inference, b)
  
          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 8 for calling a global function with example usage: single_unit(incoming, activation, bias, trainable, restore, reuse, scope, name) and returns: inference