'Convert u to tied randomness in v.'

def _u_to_v(self, log_alpha, u, eps=1e-08):

    u_prime = tf.nn.sigmoid((- log_alpha))
    v_1 = ((u - u_prime) / tf.clip_by_value((1 - u_prime), eps, 1))
    v_1 = tf.clip_by_value(v_1, 0, 1)
    v_1 = tf.stop_gradient(v_1)
    v_1 = ((v_1 * (1 - u_prime)) + u_prime)
    v_0 = (u / tf.clip_by_value(u_prime, eps, 1))
    v_0 = tf.clip_by_value(v_0, 0, 1)
    v_0 = tf.stop_gradient(v_0)
    v_0 = (v_0 * u_prime)
    v = tf.where((u > u_prime), v_1, v_0)
    v = tf.check_numerics(v, 'v    sampling    is    not    numerically    stable.')
    v = (v + tf.stop_gradient(((- v) + u)))
    return v
