class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Finds the melodic interval between the action and the last note played.
  
  Uses constants to represent special intervals like rests.
  
  Args:
    action: One-hot encoding of the chosen action
    key: The numeric values of notes belonging to this key. Defaults to
      C-major if not provided.
  Returns:
    An integer value representing the interval, or a constant value for
    special intervals.
docstr_tok: ["Finds","the","melodic","interval","between","the","action","and","the","last","note","played",".","Uses","constants","to","represent","special","intervals","like","rests",".","Args",":","action",":","One-hot","encoding","of","the","chosen","action","key",":","The","numeric","values","of","notes","belonging","to","this","key",".","Defaults","to","C-major","if","not","provided",".","Returns",":","An","integer","value","representing","the","interval",",","or","a","constant","value","for","special","intervals","."]
code: def detect_sequential_interval(self, action, key=None):
      """Finds the melodic interval between the action and the last note played.
  
      Uses constants to represent special intervals like rests.
  
      Args:
        action: One-hot encoding of the chosen action
        key: The numeric values of notes belonging to this key. Defaults to
          C-major if not provided.
      Returns:
        An integer value representing the interval, or a constant value for
        special intervals.
      """
      if not self.composition:
          return 0, None, None
  
      prev_note = self.composition[-1]
      action_note = np.argmax(action)
  
      c_major = False
      if key is None:
          key = rl_tuner_ops.C_MAJOR_KEY
          c_notes = [2, 14, 26]
          g_notes = [9, 21, 33]
          e_notes = [6, 18, 30]
          c_major = True
          tonic_notes = [2, 14, 26]
          fifth_notes = [9, 21, 33]
  
      # get rid of non-notes in prev_note
      prev_note_index = len(self.composition) - 1
      while prev_note in (NO_EVENT, NOTE_OFF) and prev_note_index >= 0:
          prev_note = self.composition[prev_note_index]
          prev_note_index -= 1
      if prev_note in (NOTE_OFF, NO_EVENT):
          tf.logging.debug(
              "Action_note: %s, prev_note: %s", action_note, prev_note
          )
          return 0, action_note, prev_note
  
      tf.logging.debug(
          "Action_note: %s, prev_note: %s", action_note, prev_note
      )
  
      # get rid of non-notes in action_note
      if action_note == NO_EVENT:
          if prev_note in tonic_notes or prev_note in fifth_notes:
              return (
                  rl_tuner_ops.HOLD_INTERVAL_AFTER_THIRD_OR_FIFTH,
                  action_note,
                  prev_note,
              )
          else:
              return rl_tuner_ops.HOLD_INTERVAL, action_note, prev_note
      elif action_note == NOTE_OFF:
          if prev_note in tonic_notes or prev_note in fifth_notes:
              return (
                  rl_tuner_ops.REST_INTERVAL_AFTER_THIRD_OR_FIFTH,
                  action_note,
                  prev_note,
              )
          else:
              return rl_tuner_ops.REST_INTERVAL, action_note, prev_note
  
      interval = abs(action_note - prev_note)
  
      if (
          c_major
          and interval == rl_tuner_ops.FIFTH
          and (prev_note in c_notes or prev_note in g_notes)
      ):
          return rl_tuner_ops.IN_KEY_FIFTH, action_note, prev_note
      if (
          c_major
          and interval == rl_tuner_ops.THIRD
          and (prev_note in c_notes or prev_note in e_notes)
      ):
          return rl_tuner_ops.IN_KEY_THIRD, action_note, prev_note
  
      return interval, action_note, prev_note
  
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 30 for calling the RLTuner obj's underlying member method code with example usage: obj.detect_sequential_interval(action, key) and returns: interval,  action_note,  prev_note, int,  None,  None, int,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note, rl_tuner_ops,  action_note,  prev_note