code: def detect_tempo(histogram, fps=None, interpolate=False):
      """
      Detect the dominant tempi from the given histogram.
  
      Parameters
      ----------
      histogram : tuple
          Histogram (tuple of 2 numpy arrays, the first giving the strengths of
          the bins and the second corresponding tempo/delay values).
      fps : float, optional
          Frames per second. If 'None', the second element is interpreted as
          tempo values. If set, the histogram's second element is interpreted as
          inter beat intervals (IBIs) in frames with the given rate.
      interpolate : bool, optional
          Interpolate the histogram bins.
  
      Returns
      -------
      tempi : numpy array
          Numpy array with the dominant tempi [bpm] (first column) and their
          relative strengths (second column).
  
      """
      from scipy.signal import argrelmax
      from scipy.interpolate import interp1d
  
      # histogram of IBIs/tempi
      bins, tempi = histogram
      # interpolate tempo
      if interpolate:
          # create interpolation function
          interpolation_fn = interp1d(tempi, bins, "quadratic")
          # generate new intervals/tempi with 100x the resolution
          tempi = np.arange(tempi[0], tempi[-1], 0.01)
          # apply quadratic interpolation
          bins = interpolation_fn(tempi)
      # if FPS is set, treat the histogram bins as intervals and convert to BPM
      if fps is not None:
          tempi = 60.0 * fps / tempi
      # peaks represent the dominant tempi
      # Note: use 'wrap' mode to also get peaks at the borders
      peaks = argrelmax(bins, mode="wrap")[0]
      if len(peaks) == 0:
          # no peaks: no tempo
          tempi = np.asarray([NO_TEMPO, 0.0])
      elif len(peaks) == 1:
          # a single peak: report only the strongest tempo
          tempi = np.asarray([tempi[peaks[0]], 1.0])
      else:
          # multiple peaks: multiple tempi
          # sort the peaks in descending order of bin heights
          sorted_peaks = peaks[np.argsort(bins[peaks])[::-1]]
          # normalize their strengths
          strengths = bins[sorted_peaks]
          strengths /= np.sum(strengths)
          # return the tempi and their normalized strengths
          tempi = np.asarray(list(zip(tempi[sorted_peaks], strengths)))
      # return detected tempi
      return np.atleast_2d(tempi)
  
imports: from __future__ import absolute_import, division, print_function
  import sys
  import warnings
  from operator import itemgetter
  import numpy
  from ..audio.signal import smooth
  from ..processors import BufferProcessor, OnlineProcessor
label_desc: Use image node_id 5 for calling a global function with example usage: detect_tempo(histogram, fps, interpolate) and returns: np