class_docstr: Builds graph for a Note RNN and instantiates weights from a checkpoint.
  
  Loads weights from a previously saved checkpoint file corresponding to a pre-
  trained basic_rnn model. Has functions that allow it to be primed with a MIDI
  melody, and allow it to be called to produce its predictions for the next
  note in a sequence.
  
  Used as part of the RLTuner class.
class_docstr_tok: ["Builds","graph","for","a","Note","RNN","and","instantiates","weights","from","a","checkpoint",".","Loads","weights","from","a","previously","saved","checkpoint","file","corresponding","to","a","pre-","trained","basic_rnn","model",".","Has","functions","that","allow","it","to","be","primed","with","a","MIDI","melody",",","and","allow","it","to","be","called","to","produce","its","predictions","for","the","next","note","in","a","sequence",".","Used","as","part","of","the","RLTuner","class","."]
docstr: Initialize by building the graph and loading a previous checkpoint.
  
  Args:
    graph: A tensorflow graph where the MelodyRNN's graph will be added.
    scope: The tensorflow scope where this network will be saved.
    checkpoint_dir: Path to the directory where the checkpoint file is saved.
    checkpoint_file: Path to a checkpoint file to be used if none can be
      found in the checkpoint_dir
    midi_primer: Path to a single midi file that can be used to prime the
      model.
    training_file_list: List of paths to tfrecord files containing melody
      training data.
    hparams: A tf_lib.HParams object. Must match the hparams used to create
      the checkpoint file.
    note_rnn_type: If 'default', will use the basic LSTM described in the
      research paper. If 'basic_rnn', will assume the checkpoint is from a
      Magenta basic_rnn model.
    checkpoint_scope: The scope in lstm which the model was originally defined
      when it was first trained.
docstr_tok: ["Initialize","by","building","the","graph","and","loading","a","previous","checkpoint",".","Args",":","graph",":","A","tensorflow","graph","where","the","MelodyRNN","'s","graph","will","be","added",".","scope",":","The","tensorflow","scope","where","this","network","will","be","saved",".","checkpoint_dir",":","Path","to","the","directory","where","the","checkpoint","file","is","saved",".","checkpoint_file",":","Path","to","a","checkpoint","file","to","be","used","if","none","can","be","found","in","the","checkpoint_dir","midi_primer",":","Path","to","a","single","midi","file","that","can","be","used","to","prime","the","model",".","training_file_list",":","List","of","paths","to","tfrecord","files","containing","melody","training","data",".","hparams",":","A","tf_lib.HParams","object",".","Must","match","the","hparams","used","to","create","the","checkpoint","file",".","note_rnn_type",":","If","'default","'",",","will","use","the","basic","LSTM","described","in","the","research","paper",".","If","'basic_rnn","'",",","will","assume","the","checkpoint","is","from","a","Magenta","basic_rnn","model",".","checkpoint_scope",":","The","scope","in","lstm","which","the","model","was","originally","defined","when","it","was","first","trained","."]
code: def __init__(
      self,
      graph,
      scope,
      checkpoint_dir,
      checkpoint_file=None,
      midi_primer=None,
      training_file_list=None,
      hparams=None,
      note_rnn_type="default",
      checkpoint_scope="rnn_model",
  ):
      """Initialize by building the graph and loading a previous checkpoint.
  
      Args:
        graph: A tensorflow graph where the MelodyRNN's graph will be added.
        scope: The tensorflow scope where this network will be saved.
        checkpoint_dir: Path to the directory where the checkpoint file is saved.
        checkpoint_file: Path to a checkpoint file to be used if none can be
          found in the checkpoint_dir
        midi_primer: Path to a single midi file that can be used to prime the
          model.
        training_file_list: List of paths to tfrecord files containing melody
          training data.
        hparams: A tf_lib.HParams object. Must match the hparams used to create
          the checkpoint file.
        note_rnn_type: If 'default', will use the basic LSTM described in the
          research paper. If 'basic_rnn', will assume the checkpoint is from a
          Magenta basic_rnn model.
        checkpoint_scope: The scope in lstm which the model was originally defined
          when it was first trained.
      """
      self.graph = graph
      self.session = None
      self.scope = scope
      self.batch_size = 1
      self.midi_primer = midi_primer
      self.checkpoint_scope = checkpoint_scope
      self.note_rnn_type = note_rnn_type
      self.training_file_list = training_file_list
      self.checkpoint_dir = checkpoint_dir
      self.checkpoint_file = checkpoint_file
  
      if hparams is not None:
          tf.logging.info("Using custom hparams")
          self.hparams = hparams
      else:
          tf.logging.info("Empty hparams string. Using defaults")
          self.hparams = rl_tuner_ops.default_hparams()
  
      self.build_graph()
      self.state_value = self.get_zero_state()
  
      if midi_primer is not None:
          self.load_primer()
  
      self.variable_names = rl_tuner_ops.get_variable_names(
          self.graph, self.scope
      )
  
      self.transpose_amount = 0
  
imports: import os
  from magenta.common import sequence_example_lib
  from magenta.models.rl_tuner import rl_tuner_ops
  from magenta.models.shared import events_rnn_graph
  from magenta.pipelines import melody_pipelines
  import note_seq
  from note_seq import midi_io
  from note_seq import sequences_lib
  import numpy
  import tensorflow.compat.v1
  import tf_slim
label_desc: Use image node_id 1 to create a new NoteRNNLoader object from inherited base classes: object with example: obj = NoteRNNLoader(graph, scope, checkpoint_dir, checkpoint_file, midi_primer, training_file_list, hparams, note_rnn_type, checkpoint_scope)