code: def test_onset_backtrack(ysr, oenv, hop, energy):
      y, sr = ysr
  
      onsets = librosa.onset.onset_detect(
          y=y,
          sr=sr,
          onset_envelope=oenv,
          hop_length=hop,
          backtrack=False,
      )
  
      # Test backtracking
      onsets_bt = librosa.onset.onset_backtrack(onsets, energy)
  
      # Make sure there are no negatives
      assert np.all(onsets_bt >= 0)
  
      # And that we never roll forward
      assert np.all(onsets_bt <= onsets)
  
      # And that the detected peaks are actually minima
      assert np.all(
          energy[onsets_bt] <= energy[np.maximum(0, onsets_bt - 1)]
      )
  
imports: import pytest
  from contextlib import nullcontext
  import os
  import warnings
  import numpy
  import librosa
  from test_core import srand
label_desc: Use image node_id 18 for calling a global function with example usage: test_onset_backtrack(ysr, oenv, hop, energy) without return types