code: def __beat_tracker(
      onset_envelope: np.ndarray,
      bpm: float,
      fft_res: float,
      tightness: float,
      trim: bool,
  ) -> np.ndarray:
      """Tracks beats in an onset strength envelope.
  
      Parameters
      ----------
      onset_envelope : np.ndarray [shape=(n,)]
          onset strength envelope
      bpm : float [scalar]
          tempo estimate
      fft_res : float [scalar]
          resolution of the fft (sr / hop_length)
      tightness : float [scalar]
          how closely do we adhere to bpm?
      trim : bool [scalar]
          trim leading/trailing beats with weak onsets?
  
      Returns
      -------
      beats : np.ndarray [shape=(n,)]
          frame numbers of beat events
      """
      if bpm <= 0:
          raise ParameterError("bpm must be strictly positive")
  
      # convert bpm to a sample period for searching
      period = round(60.0 * fft_res / bpm)
  
      # localscore is a smoothed version of AGC'd onset envelope
      localscore = __beat_local_score(onset_envelope, period)
  
      # run the DP
      backlink, cumscore = __beat_track_dp(
          localscore, period, tightness
      )
  
      # get the position of the last beat
      beats = [__last_beat(cumscore)]
  
      # Reconstruct the beat path from backlinks
      while backlink[beats[-1]] >= 0:
          beats.append(backlink[beats[-1]])
  
      # Put the beats in ascending order
      # Convert into an array of frame numbers
      beats = np.array(beats[::-1], dtype=int)
  
      # Discard spurious trailing beats
      beats = __trim_beats(localscore, beats, trim)
  
      return beats
  
file_path: librosa/librosa/beat.py
imports: import numpy
  import scipy
  import scipy.stats
  from ._cache import cache
  from .None import core
  from .None import onset
  from .None import util
  from .feature import tempogram, fourier_tempogram
  from .feature import tempo
  from .util.exceptions import ParameterError
  from .util.decorators import moved
  from typing import Any, Callable, Optional, Tuple
label_desc: Use image node_id 3 for calling a global function with example usage: __beat_tracker(onset_envelope, bpm, fft_res, tightness, trim) and returns: beats