class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Detects whether the last motif played repeats an earlier motif played.
  
  Args:
    action: One-hot encoding of the chosen action.
    bar_length: The number of beats in one bar. This determines how many beats
      the model has in which to play the motif.
  Returns:
    True if the note just played belongs to a motif that is repeated. False
    otherwise.
docstr_tok: ["Detects","whether","the","last","motif","played","repeats","an","earlier","motif","played",".","Args",":","action",":","One-hot","encoding","of","the","chosen","action",".","bar_length",":","The","number","of","beats","in","one","bar",".","This","determines","how","many","beats","the","model","has","in","which","to","play","the","motif",".","Returns",":","True","if","the","note","just","played","belongs","to","a","motif","that","is","repeated",".","False","otherwise","."]
code: def detect_repeated_motif(self, action, bar_length=8):
      """Detects whether the last motif played repeats an earlier motif played.
  
      Args:
        action: One-hot encoding of the chosen action.
        bar_length: The number of beats in one bar. This determines how many beats
          the model has in which to play the motif.
      Returns:
        True if the note just played belongs to a motif that is repeated. False
        otherwise.
      """
      composition = self.composition + [np.argmax(action)]
      if len(composition) < bar_length:
          return False, None
  
      motif, _ = self.detect_last_motif(
          composition=composition, bar_length=bar_length
      )
      if motif is None:
          return False, None
  
      prev_composition = self.composition[: -(bar_length - 1)]
  
      # Check if the motif is in the previous composition.
      for i in range(len(prev_composition) - len(motif) + 1):
          for j in range(len(motif)):
              if prev_composition[i + j] != motif[j]:
                  break
          else:
              return True, motif
      return False, None
  
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 28 for calling the RLTuner obj's underlying member method code with example usage: obj.detect_repeated_motif(action, bar_length) and returns: False,  None, False,  None, False,  None, True,  motif