class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Used to evaluate the rewards the model receives without exploring.
  
  Generates num_trials compositions and computes the note_rnn and music
  theory rewards. Uses no exploration so rewards directly relate to the
  model's policy. Stores result in internal variables.
  
  Args:
    num_trials: The number of compositions to use for evaluation.
    sample_next_obs: If True, the next note the model plays will be
      sampled from its output distribution. If False, the model will
      deterministically choose the note with maximum value.
docstr_tok: ["Used","to","evaluate","the","rewards","the","model","receives","without","exploring",".","Generates","num_trials","compositions","and","computes","the","note_rnn","and","music","theory","rewards",".","Uses","no","exploration","so","rewards","directly","relate","to","the","model","'s","policy",".","Stores","result","in","internal","variables",".","Args",":","num_trials",":","The","number","of","compositions","to","use","for","evaluation",".","sample_next_obs",":","If","True",",","the","next","note","the","model","plays","will","be","sampled","from","its","output","distribution",".","If","False",",","the","model","will","deterministically","choose","the","note","with","maximum","value","."]
code: def evaluate_model(self, num_trials=100, sample_next_obs=True):
      """Used to evaluate the rewards the model receives without exploring.
  
      Generates num_trials compositions and computes the note_rnn and music
      theory rewards. Uses no exploration so rewards directly relate to the
      model's policy. Stores result in internal variables.
  
      Args:
        num_trials: The number of compositions to use for evaluation.
        sample_next_obs: If True, the next note the model plays will be
          sampled from its output distribution. If False, the model will
          deterministically choose the note with maximum value.
      """
  
      note_rnn_rewards = [0] * num_trials
      music_theory_rewards = [0] * num_trials
      total_rewards = [0] * num_trials
  
      for t in range(num_trials):
          last_observation = self.prime_internal_models()
          self.reset_composition()
  
          for _ in range(self.num_notes_in_melody):
              _, new_observation, reward_scores = self.action(
                  last_observation,
                  0,
                  enable_random=False,
                  sample_next_obs=sample_next_obs,
              )
  
              note_rnn_reward = self.reward_from_reward_rnn_scores(
                  new_observation, reward_scores
              )
              music_theory_reward = self.reward_music_theory(
                  new_observation
              )
              adjusted_mt_reward = (
                  self.reward_scaler * music_theory_reward
              )
              total_reward = note_rnn_reward + adjusted_mt_reward
  
              note_rnn_rewards[t] = note_rnn_reward
              music_theory_rewards[t] = (
                  music_theory_reward * self.reward_scaler
              )
              total_rewards[t] = total_reward
  
              self.composition.append(np.argmax(new_observation))
              self.beat += 1
              last_observation = new_observation
  
      self.eval_avg_reward.append(np.mean(total_rewards))
      self.eval_avg_note_rnn_reward.append(np.mean(note_rnn_rewards))
      self.eval_avg_music_theory_reward.append(
          np.mean(music_theory_rewards)
      )
  
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 12 for calling the RLTuner obj's underlying member method code with example usage: obj.evaluate_model(num_trials, sample_next_obs) without return types