(rl_tuner, action, stat_dict, key=None)
return stat_dict
Computes the melodic interval just played and adds it to a stat dict.

  Args:
    rl_tuner: An RLTuner object.
    action: One-hot encoding of the chosen action.
    stat_dict: A dictionary containing fields for statistics about
      compositions.
    key: The numeric values of notes belonging to this key. Defaults to
      C-major if not provided.
  Returns:
    A dictionary of composition statistics with fields updated to include new
    intervals.
Computes the melodic interval just played and adds it to a stat dict.
Computes the melodic interval just played and adds it to a stat dict .
def add_interval_stat(rl_tuner, action, stat_dict, key=None):
  """Computes the melodic interval just played and adds it to a stat dict.

  Args:
    rl_tuner: An RLTuner object.
    action: One-hot encoding of the chosen action.
    stat_dict: A dictionary containing fields for statistics about
      compositions.
    key: The numeric values of notes belonging to this key. Defaults to
      C-major if not provided.
  Returns:
    A dictionary of composition statistics with fields updated to include new
    intervals.
  """
  interval, _, _ = rl_tuner.detect_sequential_interval(action, key)

  if interval == 0:
    return stat_dict

  if interval == rl_tuner_ops.REST_INTERVAL:
    stat_dict['num_rest_intervals'] += 1
  elif interval == rl_tuner_ops.REST_INTERVAL_AFTER_THIRD_OR_FIFTH:
    stat_dict['num_special_rest_intervals'] += 1
  elif interval > rl_tuner_ops.OCTAVE:
    stat_dict['num_octave_jumps'] += 1
  elif interval == (rl_tuner_ops.IN_KEY_FIFTH or
                    interval == rl_tuner_ops.IN_KEY_THIRD):
    stat_dict['num_in_key_preferred_intervals'] += 1
  elif interval == rl_tuner_ops.FIFTH:
    stat_dict['num_fifths'] += 1
  elif interval == rl_tuner_ops.THIRD:
    stat_dict['num_thirds'] += 1
  elif interval == rl_tuner_ops.SIXTH:
    stat_dict['num_sixths'] += 1
  elif interval == rl_tuner_ops.SECOND:
    stat_dict['num_seconds'] += 1
  elif interval == rl_tuner_ops.FOURTH:
    stat_dict['num_fourths'] += 1
  elif interval == rl_tuner_ops.SEVENTH:
    stat_dict['num_sevenths'] += 1

  return stat_dict
def add_interval_stat ( rl_tuner , action , stat_dict , key = None ) : interval , _ , _ = rl_tuner . detect_sequential_interval ( action , key ) if interval == 0 : return stat_dict if interval == rl_tuner_ops . REST_INTERVAL : stat_dict [ 'num_rest_intervals' ] += 1 elif interval == rl_tuner_ops . REST_INTERVAL_AFTER_THIRD_OR_FIFTH : stat_dict [ 'num_special_rest_intervals' ] += 1 elif interval > rl_tuner_ops . OCTAVE : stat_dict [ 'num_octave_jumps' ] += 1 elif interval == ( rl_tuner_ops . IN_KEY_FIFTH or interval == rl_tuner_ops . IN_KEY_THIRD ) : stat_dict [ 'num_in_key_preferred_intervals' ] += 1 elif interval == rl_tuner_ops . FIFTH : stat_dict [ 'num_fifths' ] += 1 elif interval == rl_tuner_ops . THIRD : stat_dict [ 'num_thirds' ] += 1 elif interval == rl_tuner_ops . SIXTH : stat_dict [ 'num_sixths' ] += 1 elif interval == rl_tuner_ops . SECOND : stat_dict [ 'num_seconds' ] += 1 elif interval == rl_tuner_ops . FOURTH : stat_dict [ 'num_fourths' ] += 1 elif interval == rl_tuner_ops . SEVENTH : stat_dict [ 'num_sevenths' ] += 1 return stat_dict