'Sets the previous reward to 0 if the same is played repeatedly.
Allows more repeated notes if there are held notes or rests in between. If
no penalty is applied will return the previous reward.
Args:
action: One-hot encoding of the chosen action.
penalty_amount: The amount the model will be penalized if it plays
repeating notes.
Returns:
Previous reward or \'penalty_amount\'.'

def reward_penalize_repeating(self, action, penalty_amount=(-100.0)):

    action_note = np.argmax(action)
    is_repeating = self.detect_repeating_notes(action_note)
    if is_repeating:
        return penalty_amount
    else:
        return 0.0
