class_docstr: This class drops portions of the input signal.
  
  Using `DropChunk` as an augmentation strategy helps a models learn to rely
  on all parts of the signal, since it can't expect a given part to be
  present.
  
  Arguments
  ---------
  drop_length_low : int
      The low end of lengths for which to set the
      signal to zero, in samples.
  drop_length_high : int
      The high end of lengths for which to set the
      signal to zero, in samples.
  drop_count_low : int
      The low end of number of times that the signal
      can be dropped to zero.
  drop_count_high : int
      The high end of number of times that the signal
      can be dropped to zero.
  drop_start : int
      The first index for which dropping will be allowed.
  drop_end : int
      The last index for which dropping will be allowed.
  noise_factor : float
      The factor relative to average amplitude of an utterance
      to use for scaling the white noise inserted. 1 keeps
      the average amplitude the same, while 0 inserts all 0's.
  
  Example
  -------
  >>> from speechbrain.dataio.dataio import read_audio
  >>> dropper = DropChunk(drop_start=100, drop_end=200, noise_factor=0.)
  >>> signal = read_audio('tests/samples/single-mic/example1.wav')
  >>> signal = signal.unsqueeze(0) # [batch, time, channels]
  >>> length = torch.ones(1)
  >>> dropped_signal = dropper(signal, length)
  >>> float(dropped_signal[:, 150])
  0.0
class_docstr_tok: ["This","class","drops","portions","of","the","input","signal",".","Using","`","DropChunk","`","as","an","augmentation","strategy","helps","a","models","learn","to","rely","on","all","parts","of","the","signal",",","since","it","ca","n't","expect","a","given","part","to","be","present",".","Arguments","--","--","--","--","-","drop_length_low",":","int","The","low","end","of","lengths","for","which","to","set","the","signal","to","zero",",","in","samples",".","drop_length_high",":","int","The","high","end","of","lengths","for","which","to","set","the","signal","to","zero",",","in","samples",".","drop_count_low",":","int","The","low","end","of","number","of","times","that","the","signal","can","be","dropped","to","zero",".","drop_count_high",":","int","The","high","end","of","number","of","times","that","the","signal","can","be","dropped","to","zero",".","drop_start",":","int","The","first","index","for","which","dropping","will","be","allowed",".","drop_end",":","int","The","last","index","for","which","dropping","will","be","allowed",".","noise_factor",":","float","The","factor","relative","to","average","amplitude","of","an","utterance","to","use","for","scaling","the","white","noise","inserted",".","1","keeps","the","average","amplitude","the","same",",","while","0","inserts","all","0","'s",".","Example","--","--","--","-",">",">",">","from","speechbrain.dataio.dataio","import","read_audio",">",">",">","dropper","=","DropChunk","(","drop_start=100",",","drop_end=200",",","noise_factor=0",".",")",">",">",">","signal","=","read_audio","(","'tests\/samples\/single-mic\/example1.wav","'",")",">",">",">","signal","=","signal.unsqueeze","(","0",")","#","[","batch",",","time",",","channels","]",">",">",">","length","=","torch.ones","(","1",")",">",">",">","dropped_signal","=","dropper","(","signal",",","length",")",">",">",">","float","(","dropped_signal","[",":",",","150","]",")","0.0"]
docstr: Arguments
  ---------
  waveforms : tensor
      Shape should be `[batch, time]` or `[batch, time, channels]`.
  lengths : tensor
      Shape should be a single dimension, `[batch]`.
  
  Returns
  -------
  Tensor of shape `[batch, time]` or
      `[batch, time, channels]`
docstr_tok: ["Arguments","--","--","--","--","-","waveforms",":","tensor","Shape","should","be","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`",".","lengths",":","tensor","Shape","should","be","a","single","dimension",",","`","[","batch","]","`",".","Returns","--","--","--","-","Tensor","of","shape","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`"]
code: def forward(self, waveforms, lengths):
      """
      Arguments
      ---------
      waveforms : tensor
          Shape should be `[batch, time]` or `[batch, time, channels]`.
      lengths : tensor
          Shape should be a single dimension, `[batch]`.
  
      Returns
      -------
      Tensor of shape `[batch, time]` or
          `[batch, time, channels]`
      """
  
      # Reading input list
      lengths = (lengths * waveforms.size(1)).long()
      batch_size = waveforms.size(0)
      dropped_waveform = waveforms.clone()
  
      # Store original amplitude for computing white noise amplitude
      clean_amplitude = compute_amplitude(
          waveforms, lengths.unsqueeze(1)
      )
  
      # Pick a number of times to drop
      drop_times = torch.randint(
          low=self.drop_count_low,
          high=self.drop_count_high + 1,
          size=(batch_size,),
      )
  
      # Iterate batch to set mask
      for i in range(batch_size):
          if drop_times[i] == 0:
              continue
  
          # Pick lengths
          length = torch.randint(
              low=self.drop_length_low,
              high=self.drop_length_high + 1,
              size=(drop_times[i],),
          )
  
          # Compute range of starting locations
          start_min = self.drop_start
          if start_min < 0:
              start_min += lengths[i]
          start_max = self.drop_end
          if start_max is None:
              start_max = lengths[i]
          if start_max < 0:
              start_max += lengths[i]
          start_max = max(0, start_max - length.max())
  
          # Pick starting locations
          start = torch.randint(
              low=start_min, high=start_max + 1, size=(drop_times[i],)
          )
  
          end = start + length
  
          # Update waveform
          if not self.noise_factor:
              for j in range(drop_times[i]):
                  dropped_waveform[i, start[j] : end[j]] = 0.0
          else:
              # Uniform distribution of -2 to +2 * avg amplitude should
              # preserve the average for normalization
              noise_max = 2 * clean_amplitude[i] * self.noise_factor
              for j in range(drop_times[i]):
                  # zero-center the noise distribution
                  noise_vec = torch.rand(
                      length[j], device=waveforms.device
                  )
                  noise_vec = 2 * noise_max * noise_vec - noise_max
                  dropped_waveform[i, start[j] : end[j]] = noise_vec
  
      return dropped_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 DropChunk obj's underlying member method code with example usage: obj.forward(waveforms, lengths) and returns: dropped_waveform