import tensorflow as tf

        var = tf.get_variable(name, shape=shape, dtype=dtype, initializer=initializer, trainable=trainable)

        # Add L2 regularization node for trainable var
        if trainable and not no_reg:
            l2_loss = tf.nn.l2_loss(var)
            tf.add_to_collection(tf.GraphKeys.REGULARIZATION_LOSSES, l2_loss)

        return var
