class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: 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'.
docstr_tok: ["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","'","."]
code: def reward_penalize_repeating(self, action, penalty_amount=-100.0):
      """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'.
      """
      action_note = np.argmax(action)
      is_repeating = self.detect_repeating_notes(action_note)
      if is_repeating:
          return penalty_amount
      else:
          return 0.0
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import random
  import urllib
  from magenta.models.rl_tuner import note_rnn_loader
  from magenta.models.rl_tuner import rl_tuner_eval_metrics
  from magenta.models.rl_tuner import rl_tuner_ops
  import matplotlib.pyplot
  from note_seq import melodies_lib
  from note_seq import midi_io
  import numpy
  import scipy.special
  from six.moves import range
  from six.moves import reload_module
  from six.moves import urllib
  import tensorflow.compat.v1
label_desc: Use image node_id 24 for calling the RLTuner obj's underlying member method code with example usage: obj.reward_penalize_repeating(action, penalty_amount) and returns: penalty_amount, int