class_docstr: This function mimics audio clipping by clamping the input tensor.
  First, it normalizes the waveforms from -1 to -1. Then, clipping is applied.
  Finally, the original amplitude is restored.
  
  Arguments
  ---------
  clip_low : float
      The low end of amplitudes for which to clip the signal.
  clip_high : float
      The high end of amplitudes for which to clip the signal.
  
  Example
  -------
  >>> from speechbrain.dataio.dataio import read_audio
  >>> clipper = DoClip(clip_low=0.01, clip_high=0.01)
  >>> signal = read_audio('tests/samples/single-mic/example1.wav')
  >>> clipped_signal = clipper(signal.unsqueeze(0))
class_docstr_tok: ["This","function","mimics","audio","clipping","by","clamping","the","input","tensor",".","First",",","it","normalizes","the","waveforms","from","-1","to","-1",".","Then",",","clipping","is","applied",".","Finally",",","the","original","amplitude","is","restored",".","Arguments","--","--","--","--","-","clip_low",":","float","The","low","end","of","amplitudes","for","which","to","clip","the","signal",".","clip_high",":","float","The","high","end","of","amplitudes","for","which","to","clip","the","signal",".","Example","--","--","--","-",">",">",">","from","speechbrain.dataio.dataio","import","read_audio",">",">",">","clipper","=","DoClip","(","clip_low=0.01",",","clip_high=0.01",")",">",">",">","signal","=","read_audio","(","'tests\/samples\/single-mic\/example1.wav","'",")",">",">",">","clipped_signal","=","clipper","(","signal.unsqueeze","(","0",")",")"]
docstr: Arguments
  ---------
  waveforms : tensor
      Shape should be `[batch, time]` or `[batch, time, channels]`.
  
  Returns
  -------
  Tensor of shape `[batch, time]` or `[batch, time, channels]`
docstr_tok: ["Arguments","--","--","--","--","-","waveforms",":","tensor","Shape","should","be","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`",".","Returns","--","--","--","-","Tensor","of","shape","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`"]
code: def forward(self, waveforms):
      """
      Arguments
      ---------
      waveforms : tensor
          Shape should be `[batch, time]` or `[batch, time, channels]`.
  
      Returns
      -------
      Tensor of shape `[batch, time]` or `[batch, time, channels]`
      """
  
      # Normalize the signal
      abs_max, _ = torch.max(torch.abs(waveforms), dim=1, keepdim=True)
      waveforms = waveforms / abs_max
  
      # Randomly select clip value
      clipping_range = self.clip_high - self.clip_low
      clip_value = (
          torch.rand(1, device=waveforms.device)[0] * clipping_range
          + self.clip_low
      )
  
      # Apply clipping
      clipped_waveform = waveforms.clamp(-clip_value, clip_value)
  
      # Restore orignal amplitude
      clipped_waveform = clipped_waveform * abs_max / clip_value
  
      return clipped_waveform
  
imports: import math
  import random
  import torch
  import torch.nn.functional
  from speechbrain.dataio.legacy import ExtendedCSVDataset
  from speechbrain.dataio.dataloader import make_dataloader
  from speechbrain.processing.signal_processing import compute_amplitude, dB_to_amplitude, convolve1d, notch_filter, reverberate
label_desc: Use image node_id 2 for calling the DoClip obj's underlying member method code with example usage: obj.forward(waveforms) and returns: clipped_waveform