import tensorflow as tf

    tgt_dif = tgt_flat1 - tgt_flat2
    pred_dif = pred_flat1 - pred_flat2
    geq = tf.cast(tgt_dif > 0, tf.bool)
    tgt_posi_dif = tf.where(geq, tgt_dif, -tgt_dif)
    pred_posi_dif = tf.where(geq, pred_dif, -pred_dif)
    loss = tf.maximum(0., tgt_posi_dif - pred_posi_dif)
    cstr_pct = tf.math.count_nonzero(loss, dtype=tf.float32) / tf.cast(tf.reduce_prod(tf.shape(loss)), tf.float32)

    unorm_w = tf.exp((tgt_flat1 + tgt_flat2)/temp)
    loss = unorm_w * loss / (tf.reduce_sum(unorm_w))

    a = tf.print(tf.reduce_sum(unorm_w))
