class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Plots the cumulative rewards received as the model was trained.
  
  If image_name is None, should be used in jupyter notebook. If
  called outside of jupyter, execution of the program will halt and
  a pop-up with the graph will appear. Execution will not continue
  until the pop-up is closed.
  
  Args:
    image_name: Name to use when saving the plot to a file. If not
      provided, image will be shown immediately.
    directory: Path to directory where figure should be saved. If
      None, defaults to self.output_dir.
docstr_tok: ["Plots","the","cumulative","rewards","received","as","the","model","was","trained",".","If","image_name","is","None",",","should","be","used","in","jupyter","notebook",".","If","called","outside","of","jupyter",",","execution","of","the","program","will","halt","and","a","pop-up","with","the","graph","will","appear",".","Execution","will","not","continue","until","the","pop-up","is","closed",".","Args",":","image_name",":","Name","to","use","when","saving","the","plot","to","a","file",".","If","not","provided",",","image","will","be","shown","immediately",".","directory",":","Path","to","directory","where","figure","should","be","saved",".","If","None",",","defaults","to","self.output_dir","."]
code: def plot_rewards(self, image_name=None, directory=None):
      """Plots the cumulative rewards received as the model was trained.
  
      If image_name is None, should be used in jupyter notebook. If
      called outside of jupyter, execution of the program will halt and
      a pop-up with the graph will appear. Execution will not continue
      until the pop-up is closed.
  
      Args:
        image_name: Name to use when saving the plot to a file. If not
          provided, image will be shown immediately.
        directory: Path to directory where figure should be saved. If
          None, defaults to self.output_dir.
      """
      if directory is None:
          directory = self.output_dir
  
      reward_batch = self.output_every_nth
      x = [
          reward_batch * i for i in np.arange(len(self.rewards_batched))
      ]
      plt.figure()
      plt.plot(x, self.rewards_batched)
      plt.plot(x, self.music_theory_rewards_batched)
      plt.plot(x, self.note_rnn_rewards_batched)
      plt.xlabel("Training epoch")
      plt.ylabel(
          "Cumulative reward for last " + str(reward_batch) + " steps"
      )
      plt.legend(["Total", "Music theory", "Note RNN"], loc="best")
      if image_name is not None:
          plt.savefig(directory + "/" + image_name)
      else:
          plt.show()
  
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 43 for calling the RLTuner obj's underlying member method code with example usage: obj.plot_rewards(image_name, directory) without return types