import tensorflow as tf

        maxnorm: the maximum Euclidean norm
        
    Returns:
        An operation that will update var_matrix when run in a Session
    '''
    row_norms = tf.sqrt(tf.reduce_sum(tf.square(var_matrix), 1))
    scaling = maxnorm / tf.maximum(row_norms, maxnorm)
    scaled = var_matrix * tf.expand_dims(scaling, 1)
    return tf.assign(var_matrix, scaled)


def dense_maxnorm(var_matrix, maxnorm=1.0):
    '''Similar to dense_maxnorm_update(), except this returns a new Tensor
       instead of an operation that modifies var_matrix.

    Args:
