class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Applies punishment and reward based on the principle leap up leap back.
  
  Large interval jumps (more than a fifth) should be followed by moving back
  in the same direction.
  
  Args:
    action: One-hot encoding of the chosen action.
    resolving_leap_bonus: Amount of reward dispensed for resolving a previous
      leap.
    leaping_twice_punishment: Amount of reward received for leaping twice in
      the same direction.
  Returns:
    Float reward value.
docstr_tok: ["Applies","punishment","and","reward","based","on","the","principle","leap","up","leap","back",".","Large","interval","jumps","(","more","than","a","fifth",")","should","be","followed","by","moving","back","in","the","same","direction",".","Args",":","action",":","One-hot","encoding","of","the","chosen","action",".","resolving_leap_bonus",":","Amount","of","reward","dispensed","for","resolving","a","previous","leap",".","leaping_twice_punishment",":","Amount","of","reward","received","for","leaping","twice","in","the","same","direction",".","Returns",":","Float","reward","value","."]
code: def reward_leap_up_back(
      self,
      action,
      resolving_leap_bonus=5.0,
      leaping_twice_punishment=-5.0,
  ):
      """Applies punishment and reward based on the principle leap up leap back.
  
      Large interval jumps (more than a fifth) should be followed by moving back
      in the same direction.
  
      Args:
        action: One-hot encoding of the chosen action.
        resolving_leap_bonus: Amount of reward dispensed for resolving a previous
          leap.
        leaping_twice_punishment: Amount of reward received for leaping twice in
          the same direction.
      Returns:
        Float reward value.
      """
  
      leap_outcome = self.detect_leap_up_back(action)
      if leap_outcome == rl_tuner_ops.LEAP_RESOLVED:
          tf.logging.debug(
              "Leap resolved, awarding %s", resolving_leap_bonus
          )
          return resolving_leap_bonus
      elif leap_outcome == rl_tuner_ops.LEAP_DOUBLED:
          tf.logging.debug(
              "Leap doubled, awarding %s", leaping_twice_punishment
          )
          return leaping_twice_punishment
      else:
          return 0.0
  
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 36 for calling the RLTuner obj's underlying member method code with example usage: obj.reward_leap_up_back(action, resolving_leap_bonus, leaping_twice_punishment) and returns: resolving_leap_bonus, leaping_twice_punishment, int