'Calls whatever reward function is indicated in the reward_mode field.
New reward functions can be written and called from here. Note that the
reward functions can make use of the musical composition that has been
played so far, which is stored in self.composition. Some reward functions
are made up of many smaller functions, such as those related to music
theory.
Args:
obs: A one-hot encoding of the observed note.
action: A one-hot encoding of the chosen action.
reward_scores: The value for each note output by the reward_rnn.
Returns:
Float reward value.'

def collect_reward(self, obs, action, reward_scores):

    note_rnn_reward = self.reward_from_reward_rnn_scores(action, reward_scores)
    self.note_rnn_reward_last_n += note_rnn_reward
    if (self.reward_mode == 'scale'):
        reward = self.reward_scale(obs, action)
    elif (self.reward_mode == 'key'):
        reward = self.reward_key_distribute_prob(action)
    elif (self.reward_mode == 'key_and_tonic'):
        reward = self.reward_key(action)
        reward += self.reward_tonic(action)
    elif (self.reward_mode == 'non_repeating'):
        reward = self.reward_non_repeating(action)
    elif (self.reward_mode == 'music_theory_random'):
        reward = self.reward_key(action)
        reward += self.reward_tonic(action)
        reward += self.reward_penalize_repeating(action)
    elif (self.reward_mode == 'music_theory_basic'):
        reward = self.reward_key(action)
        reward += self.reward_tonic(action)
        reward += self.reward_penalize_repeating(action)
        return ((reward * self.reward_scaler) + note_rnn_reward)
    elif (self.reward_mode == 'music_theory_basic_plus_variety'):
        reward = self.reward_key(action)
        reward += self.reward_tonic(action)
        reward += self.reward_penalize_repeating(action)
        reward += self.reward_penalize_autocorrelation(action)
        return ((reward * self.reward_scaler) + note_rnn_reward)
    elif (self.reward_mode == 'preferred_intervals'):
        reward = self.reward_preferred_intervals(action)
    elif (self.reward_mode == 'music_theory_all'):
        tf.logging.debug('Note    RNN    reward:    %s', note_rnn_reward)
        reward = self.reward_music_theory(action)
        tf.logging.debug('Total    music    theory    reward:    %s', (self.reward_scaler * reward))
        tf.logging.debug('Total    note    rnn    reward:    %s', note_rnn_reward)
        self.music_theory_reward_last_n += (reward * self.reward_scaler)
        return ((reward * self.reward_scaler) + note_rnn_reward)
    elif (self.reward_mode == 'music_theory_only'):
        reward = self.reward_music_theory(action)
    else:
        tf.logging.fatal('ERROR!    Not    a    valid    reward    mode.    Cannot    compute    reward')
    self.music_theory_reward_last_n += (reward * self.reward_scaler)
    return (reward * self.reward_scaler)
