code: def test_add_reverb(tmpdir, device):
      from speechbrain.augment.time_domain import AddReverb
  
      test_waveform = torch.sin(
          torch.arange(16000.0, device=device)
      ).unsqueeze(0)
      impulse_response = torch.zeros(1, 8000, device=device)
      impulse_response[0, 0] = 1.0
  
      # Put ir waveform into temporary file
      ir1 = os.path.join(tmpdir, "ir1.wav")
      ir2 = os.path.join(tmpdir, "ir2.wav")
      ir3 = os.path.join(tmpdir, "ir3.wav")
      write_audio(ir1, impulse_response.cpu().transpose(0, 1), 16000)
  
      impulse_response[0, 0] = 0.0
      impulse_response[0, 10] = 0.5
      write_audio(ir2, impulse_response.cpu().transpose(0, 1), 16000)
  
      # Check a very simple non-impulse-response case:
      impulse_response[0, 10] = 0.6
      impulse_response[0, 11] = 0.4
      # sf.write(ir3, impulse_response.squeeze(0).numpy(), 16000)
      write_audio(ir3, impulse_response.cpu().transpose(0, 1), 16000)
      ir3_result = test_waveform * 0.6 + test_waveform.roll(1, -1) * 0.4
  
      # write ir csv file
      csv = os.path.join(tmpdir, "ir.csv")
      with open(csv, "w") as w:
          w.write("ID, duration, wav, wav_format, wav_opts\n")
          w.write(f"1, 0.5, {ir1}, wav,\n")
          w.write(f"2, 0.5, {ir2}, wav,\n")
          w.write(f"3, 0.5, {ir3}, wav,\n")
  
      # Normal cases
      add_reverb = AddReverb(csv, sorting="original")
      reverbed = add_reverb(test_waveform)[:, 0:1000]
      assert reverbed.allclose(test_waveform[:, 0:1000], atol=1e-1)
      reverbed = add_reverb(test_waveform)[:, 0:1000]
      assert reverbed.allclose(test_waveform[:, 0:1000], atol=1e-1)
      reverbed = add_reverb(test_waveform)[:, 0:1000]
      assert reverbed.allclose(ir3_result[:, 0:1000], atol=2e-1)
  
file_path: speechbrain/tests/unittests/test_augment.py
imports: import os
  import torch
  import torchaudio
  from speechbrain.dataio.dataio import write_audio
label_desc: Use image node_id 2 for calling a global function with example usage: test_add_reverb(tmpdir, device) without return types