code: def _get_reasonable_f0_min_max(
      f0_midi, max_spike=5.0, min_midi_value=5.0, pad=6.0
  ):
      """Find the min and max for an f0 plot, ignoring spike glitches and low notes.
  
       This function finds the min and max of the f0 after two operations to omit
       values. The first does np.diff() to examine the difference between adjacent
       values in the f0 curve. Values in abs(diff) above `max_spikes` are omitted.
       The second operation excludes MIDI notes below a threshold as determined by
       `min_midi_values`. After those two operations the min and max are found, and
       a padding (`pad`) value is added to the max and subtracted from the min
       before returning.
  
      Args:
        f0_midi: f0 curve in MIDI space.
        max_spike: Max value between successive diff values that will be included
          in the final min/max calculation.
        min_midi_value: Any MIDI values below this number will not be included in
          the final min/max calulation.
        pad: Value that will be added to the max and subtracted from the min.
  
      Returns:
        min_, max_: Values for an f0 plot that enphasizes the parts we care about.
  
      """
  
      # Mask out the 'spikes' by thresholding the diff above a value.
      diff = np.diff(f0_midi)
      diff = np.insert(diff, 0, 0.0)
      diff_mask = np.ma.masked_outside(diff, -max_spike, max_spike)
  
      # Remove any notes below the min.
      f0_mask = np.ma.masked_less(f0_midi, min_midi_value)
  
      # Combine the two masked arrays
      comb_masks = np.ma.array(
          f0_midi, mask=np.logical_or(diff_mask.mask, f0_mask.mask)
      )
  
      # Comute min/max with the padding and return.
      min_ = np.floor(np.min(comb_masks) - pad)
      max_ = np.ceil(np.max(comb_masks) + pad)
      return min_, max_
  
imports: import io
  import ddsp
  from ddsp.core import tf_float32
  from ddsp.training.plotting import pianoroll_plot_setup
  import matplotlib.patches
  import matplotlib.pyplot
  from matplotlib.ticker import MaxNLocator
  import note_seq
  from note_seq import sequences_lib
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 9 for calling a global function with example usage: _get_reasonable_f0_min_max(f0_midi, max_spike, min_midi_value, pad) and returns: min_,  max_