code: def _phase_deviation(phase):
      """
      Helper function used by phase_deviation() & weighted_phase_deviation().
  
      Parameters
      ----------
      phase : numpy array
          Phase of the STFT.
  
      Returns
      -------
      numpy array
          Phase deviation.
  
      """
      pd = np.zeros_like(phase)
      # instantaneous frequency is given by the first difference
      # ψ′(n, k) = ψ(n, k) − ψ(n − 1, k)
      # change in instantaneous frequency is given by the second order difference
      # ψ′′(n, k) = ψ′(n, k) − ψ′(n − 1, k)
      pd[2:] = phase[2:] - 2 * phase[1:-1] + phase[:-2]
      # map to the range -pi..pi
      return np.asarray(wrap_to_pi(pd))
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  from scipy.ndimage import maximum_filter, minimum_filter, uniform_filter
  from ..audio.signal import smooth
  from ..processors import BufferProcessor, OnlineProcessor, ParallelProcessor, SequentialProcessor
  from ..utils import combine_events
label_desc: Use image node_id 9 for calling a global function with example usage: _phase_deviation(phase) and returns: np