class_docstr: This function combines segments (with equal length in time) of the time series contained in the batch.
  Proposed for EEG signals in https://doi.org/10.1016/j.neunet.2021.05.032.
  
  Arguments
  ---------
  min_num_segments : int
      The number of segments to combine.
  max_num_segments : int
      The maximum number of segments to combine. Default is 10.
  
  Example
  -------
  >>> signal = torch.ones((4, 256, 22)) * torch.arange(4).reshape((4, 1, 1,))
  >>> cutcat =  CutCat()
  >>> output_signal = cutcat(signal)
class_docstr_tok: ["This","function","combines","segments","(","with","equal","length","in","time",")","of","the","time","series","contained","in","the","batch",".","Proposed","for","EEG","signals","in","https",":","\/\/doi.org\/10.1016\/j.neunet.2021.05.032",".","Arguments","--","--","--","--","-","min_num_segments",":","int","The","number","of","segments","to","combine",".","max_num_segments",":","int","The","maximum","number","of","segments","to","combine",".","Default","is","10",".","Example","--","--","--","-",">",">",">","signal","=","torch.ones","(","(","4",",","256",",","22",")",")","*","torch.arange","(","4",")",".reshape","(","(","4",",","1",",","1",",",")",")",">",">",">","cutcat","=","CutCat","(",")",">",">",">","output_signal","=","cutcat","(","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]`
      """
      if (
          waveforms.shape[0] > 1
      ):  # only if there are at least 2 examples in batch
          # rolling waveforms to point to segments of other examples in batch
          waveforms_rolled = torch.roll(waveforms, shifts=1, dims=0)
          # picking number of segments to use
          num_segments = torch.randint(
              low=self.min_num_segments,
              high=self.max_num_segments + 1,
              size=(1,),
          )
          # index of cuts (both starts and stops)
          idx_cut = torch.linspace(
              0,
              waveforms.shape[1],
              num_segments.item() + 1,
              dtype=torch.int,
          )
          for i in range(idx_cut.shape[0] - 1):
              # half of segments from other examples in batch
              if i % 2 == 1:
                  start = idx_cut[i]
                  stop = idx_cut[i + 1]
                  waveforms[:, start:stop, ...] = waveforms_rolled[
                      :, start:stop, ...  # noqa: W504
                  ]
  
      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 CutCat obj's underlying member method code with example usage: obj.forward(waveforms) and returns: waveforms