import tensorflow as tf

    def sample_compute(_):
        pairs = sample_func()
        loss = compute_contra_loss(*pairs, hard_ratio=hard_ratio)
        pct = tf.math.count_nonzero(loss, dtype=tf.float32) / tf.size(loss, out_type=tf.float32)

        p = tf.cond(tf.random_uniform((), dtype=tf.float32) < 1e-4,
