code: def spectral_flux(spectrogram, diff_frames=None):
      """
      Spectral Flux.
  
      Parameters
      ----------
      spectrogram : :class:`Spectrogram` instance
          Spectrogram instance.
      diff_frames : int, optional
          Number of frames to calculate the diff to.
  
      Returns
      -------
      spectral_flux : numpy array
          Spectral flux onset detection function.
  
      References
      ----------
      .. [1] Paul Masri,
             "Computer Modeling of Sound for Transformation and Synthesis of
             Musical Signals",
             PhD thesis, University of Bristol, 1996.
  
      """
      from madmom.audio.spectrogram import SpectrogramDifference
  
      # if the diff of a spectrogram is given, do not calculate the diff twice
      if not isinstance(spectrogram, SpectrogramDifference):
          spectrogram = spectrogram.diff(
              diff_frames=diff_frames, positive_diffs=True
          )
      # Spectral flux is the sum of all positive 1st order differences
      return np.asarray(np.sum(spectrogram, axis=1))
  
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 5 for calling a global function with example usage: spectral_flux(spectrogram, diff_frames) and returns: np