class_docstr: This function randomly swaps N channels.
  
  Arguments
  ---------
  min_swap : int
      The mininum number of channels to swap.
  max_swap : int
      The maximum number of channels to swap.
  
  Example
  -------
  >>> signal = torch.rand(4, 256, 8)
  >>> ch_swap = ChannelSwap()
  >>> output_signal = ch_swap(signal)
class_docstr_tok: ["This","function","randomly","swaps","N","channels",".","Arguments","--","--","--","--","-","min_swap",":","int","The","mininum","number","of","channels","to","swap",".","max_swap",":","int","The","maximum","number","of","channels","to","swap",".","Example","--","--","--","-",">",">",">","signal","=","torch.rand","(","4",",","256",",","8",")",">",">",">","ch_swap","=","ChannelSwap","(",")",">",">",">","output_signal","=","ch_swap","(","signal",")"]
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]`
      """
  
      # Pick a frequency to drop
      rand_perm1 = torch.randperm(waveforms.shape[-1])
      rand_perm2 = torch.randperm(waveforms.shape[-1])
      N_swaps = torch.randint(
          low=self.min_swap, high=self.max_swap + 1, size=(1,)
      )
  
      if N_swaps < waveforms.shape[-1]:
          for i in range(N_swaps):
              store_channel = waveforms[:, :, rand_perm2[i]]
              waveforms[:, :, rand_perm2[i]] = waveforms[
                  :, :, rand_perm1[i]
              ]
              waveforms[:, :, rand_perm1[i]] = store_channel
      else:
          # Full swap
          waveforms = waveforms[:, :, rand_perm1]
  
      return waveforms
  
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 ChannelSwap obj's underlying member method code with example usage: obj.forward(waveforms) and returns: waveforms