def variable(name, shape=None, dtype=tf.float32, initializer=None,
             regularizer=None, trainable=True, collections=None, device='',
             restore=True):
    """ variable.

    Instantiate a new variable.

    Arguments:
        name: `str`. A name for this variable.
        shape: list of `int`. The variable shape (optional).
        dtype: `type`. The variable data type.
        initializer: `str` or `Tensor`. The variable initialization. (See
            tflearn.initializations for references).
        regularizer: `str` or `Tensor`. The variable regularizer. (See
            tflearn.losses for references).
        trainable: `bool`. If True, this variable weights will be trained.
        collections: `str`. A collection to add the new variable to (optional).
        device: `str`. Device ID to store the variable. Default: '/cpu:0'.
        restore: `bool`. Restore or not this variable when loading a
            pre-trained model (Only compatible with tflearn pre-built
            training functions).

    Returns:
        A Variable.

    """

    if isinstance(initializer, str):
        initializer = tflearn.initializations.get(initializer)()

    if isinstance(regularizer, str):
        regularizer = tflearn.losses.get(regularizer)

    with tf.device(device):

        try:
            var = tf.get_variable(name, shape=shape, dtype=dtype,
                                  initializer=initializer,
                                  regularizer=regularizer,
                                  trainable=trainable,
                                  collections=collections)
        # Fix for old TF versions
        except Exception as e:
            var = tf.get_variable(name, shape=shape, dtype=dtype,
                                  initializer=initializer,
                                  trainable=trainable,
                                  collections=collections)
            if regularizer is not None:
                tflearn.add_weights_regularizer(var, regularizer)

        if not restore:
            tf.add_to_collection(tf.GraphKeys.EXCL_RESTORE_VARS, var)

        return var
dataset/ETHPy150Open tflearn/tflearn/tflearn/variables.py/variable/original