class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Prime an internal model such as the q_network based on priming mode.
  
  Args:
    model: The internal model that should be primed.
  
  Returns:
    The first observation to feed into the model.
docstr_tok: ["Prime","an","internal","model","such","as","the","q_network","based","on","priming","mode",".","Args",":","model",":","The","internal","model","that","should","be","primed",".","Returns",":","The","first","observation","to","feed","into","the","model","."]
code: def prime_internal_model(self, model):
      """Prime an internal model such as the q_network based on priming mode.
  
      Args:
        model: The internal model that should be primed.
  
      Returns:
        The first observation to feed into the model.
      """
      model.state_value = model.get_zero_state()
  
      if self.priming_mode == "random_midi":
          priming_idx = np.random.randint(0, len(self.priming_states))
          model.state_value = np.reshape(
              self.priming_states[priming_idx, :],
              (1, model.cell.state_size),
          )
          priming_note = self.priming_notes[priming_idx]
          next_obs = np.array(
              rl_tuner_ops.make_onehot([priming_note], self.num_actions)
          ).flatten()
          tf.logging.debug(
              "Feeding priming state for midi file %s and corresponding note %s",
              priming_idx,
              priming_note,
          )
      elif self.priming_mode == "single_midi":
          model.prime_model()
          next_obs = model.priming_note
      elif self.priming_mode == "random_note":
          next_obs = self.get_random_note()
      else:
          tf.logging.warn(
              "Error! Invalid priming mode. Priming with random note"
          )
          next_obs = self.get_random_note()
  
      return next_obs
  
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 4 for calling the RLTuner obj's underlying member method code with example usage: obj.prime_internal_model(model) and returns: next_obs