code: def test_drop_chunk(device):
      from speechbrain.augment.time_domain import DropChunk
  
      test_waveform = torch.sin(
          torch.arange(16000.0, device=device)
      ).unsqueeze(0)
      lengths = torch.ones(1, device=device)
  
      # Edge cases
      no_drop = DropChunk(drop_length_low=0, drop_length_high=0).to(
          device
      )
      assert no_drop(test_waveform, lengths).allclose(test_waveform)
      no_drop = DropChunk(drop_count_low=0, drop_count_high=0).to(
          device
      )
      assert no_drop(test_waveform, lengths).allclose(test_waveform)
      no_drop = DropChunk(drop_start=0, drop_end=0).to(device)
      assert no_drop(test_waveform, lengths).allclose(test_waveform)
  
      # Specify all parameters to ensure it is deterministic
      dropper = DropChunk(
          drop_length_low=100,
          drop_length_high=100,
          drop_count_low=1,
          drop_count_high=1,
          drop_start=100,
          drop_end=200,
          noise_factor=0.0,
      ).to(device)
      expected_waveform = test_waveform.clone()
      expected_waveform[:, 100:200] = 0.0
  
      assert dropper(test_waveform, lengths).allclose(expected_waveform)
  
      # Make sure amplitude is similar before and after
      dropper = DropChunk(noise_factor=1.0).to(device)
      drop_amplitude = dropper(test_waveform, lengths).abs().mean()
      orig_amplitude = test_waveform.abs().mean()
      assert drop_amplitude.allclose(orig_amplitude, atol=1e-2)
  
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 5 for calling a global function with example usage: test_drop_chunk(device) without return types