import tensorflow as tf

    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

