'Reduces the previous reward if the composition is highly autocorrelated.
Penalizes the model for creating a composition that is highly correlated
with itself at lags of 1, 2, and 3 beats previous. This is meant to
encourage variety in compositions.
Args:
action: One-hot encoding of the chosen action.
penalty_weight: The default weight which will be multiplied by the sum
of the autocorrelation coefficients, and subtracted from prev_reward.
Returns:
Float reward value.'

def reward_penalize_autocorrelation(self, action, penalty_weight=3.0):

    composition = (self.composition + [np.argmax(action)])
    lags = [1, 2, 3]
    sum_penalty = 0
    for lag in lags:
        coeff = rl_tuner_ops.autocorrelate(composition, lag=lag)
        if (not np.isnan(coeff)):
            if (np.abs(coeff) > 0.15):
                sum_penalty += (np.abs(coeff) * penalty_weight)
    return (- sum_penalty)
