import tensorflow as tf

    t1, t2 = tf.split(traj_tgt, 2, axis=0)
    soft_sign = tf.tanh((t1 - t2) * temp)
    loss = tf.maximum(0.0, soft_sign * ((t1 - t2) - (p1 - p2)))
    loss = tf.reduce_mean(loss)
    return loss


def horizon_sumV1(input, horizon=12):
    bs, epi_len = input.shape[:2]
    new_w = epi_len - horizon + 1
    weights = np.zeros([epi_len, new_w])
    for i in range(new_w):
        weights[i:i + horizon, i] = 1.0
    weights = tf.convert_to_tensor(weights, dtype=tf.float32)
    horizon_sum = tf.matmul(input, weights)
    return horizon_sum


def horizon_sumV2(pred, tgt, horizon=12):
    bs, epi_len = 50, 50
    weights_list = []
    for h in range(1, horizon + 1):
        new_w = epi_len - h + 1
        weights = np.zeros([epi_len, epi_len])
        for i in range(new_w):
            weights[i:i + h, i] = 1.0
        weights_list += [weights]
    weights_tensors = tf.stack([tf.convert_to_tensor(weights, dtype=tf.float32) for weights in weights_list])
