(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.
Adds a big bonus to previous reward if the model plays a repeated motif.
Adds a big bonus to previous reward if the model plays a repeated motif .
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
def reward_repeated_motif ( self , action , bar_length = 8 , reward_amount = 4.0 ) : 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