import tensorflow as tf


    Returns:
        A new tensor where all rows have been scaled as necessary
    '''
    axis_norms = tf.sqrt(tf.reduce_sum(tf.square(var_matrix), 1))
    scaling = maxnorm / tf.maximum(axis_norms, maxnorm)
    return var_matrix * tf.expand_dims(scaling, 1)

