class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Adds a big bonus to previous reward if the model plays a repeated motif.
  
  Checks if the model has just played a motif that repeats an ealier motif in
  the composition.
  
  There is also a bonus for repeating more complex motifs.
  
  Args:
    action: One-hot encoding of the chosen action.
    bar_length: The number of notes in one bar.
    reward_amount: The amount that will be added to the reward if the last
      note belongs to a repeated motif.
  Returns:
    Float reward value.
docstr_tok: ["Adds","a","big","bonus","to","previous","reward","if","the","model","plays","a","repeated","motif",".","Checks","if","the","model","has","just","played","a","motif","that","repeats","an","ealier","motif","in","the","composition",".","There","is","also","a","bonus","for","repeating","more","complex","motifs",".","Args",":","action",":","One-hot","encoding","of","the","chosen","action",".","bar_length",":","The","number","of","notes","in","one","bar",".","reward_amount",":","The","amount","that","will","be","added","to","the","reward","if","the","last","note","belongs","to","a","repeated","motif",".","Returns",":","Float","reward","value","."]
code: def reward_repeated_motif(
      self, action, bar_length=8, reward_amount=4.0
  ):
      """Adds a big bonus to previous reward if the model plays a repeated motif.
  
      Checks if the model has just played a motif that repeats an ealier motif in
      the composition.
  
      There is also a bonus for repeating more complex motifs.
  
      Args:
        action: One-hot encoding of the chosen action.
        bar_length: The number of notes in one bar.
        reward_amount: The amount that will be added to the reward if the last
          note belongs to a repeated motif.
      Returns:
        Float reward value.
      """
      is_repeated, motif = self.detect_repeated_motif(
          action, bar_length
      )
      if is_repeated:
          actual_notes = [
              a for a in motif if a not in (NO_EVENT, NOTE_OFF)
          ]
          num_notes_in_motif = len(set(actual_notes))
          motif_complexity_bonus = max(num_notes_in_motif - 3, 0)
          return reward_amount + motif_complexity_bonus
      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 29 for calling the RLTuner obj's underlying member method code with example usage: obj.reward_repeated_motif(action, bar_length, reward_amount) and returns: unknown, int