code: def test_onset_units(ysr, hop_length, units, ctx):
      y, sr = ysr
  
      with ctx:
          b1 = librosa.onset.onset_detect(
              y=y, sr=sr, hop_length=hop_length
          )
          b2 = librosa.onset.onset_detect(
              y=y, sr=sr, hop_length=hop_length, units=units
          )
  
          t1 = librosa.frames_to_time(b1, sr=sr, hop_length=hop_length)
  
          if units == "time":
              t2 = b2
  
          elif units == "samples":
              t2 = librosa.samples_to_time(b2, sr=sr)
  
          elif units == "frames":
              t2 = librosa.frames_to_time(
                  b2, sr=sr, hop_length=hop_length
              )
  
          else:
              assert False
  
          assert np.allclose(t1, t2)
  
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 16 for calling a global function with example usage: test_onset_units(ysr, hop_length, units, ctx) without return types