class_docstr: This class convolves an audio signal with an impulse response.
  
  Arguments
  ---------
  csv_file : str
      The name of a csv file containing the location of the
      impulse response files.
  sorting : str
      The order to iterate the csv file, from one of
      the following options: random, original, ascending, and descending.
  num_workers : int
      Number of workers in the DataLoader (See PyTorch DataLoader docs).
  rir_scale_factor: float
      It compresses or dilates the given impulse response.
      If 0 < scale_factor < 1, the impulse response is compressed
      (less reverb), while if scale_factor > 1 it is dilated
      (more reverb).
  replacements : dict
      A set of string replacements to carry out in the
      csv file. Each time a key is found in the text, it will be replaced
      with the corresponding value.
  reverb_sample_rate : int
      The sample rate of the corruption signals (rirs), so that they
      can be resampled to clean sample rate if necessary.
  clean_sample_rate : int
      The sample rate of the clean signals, so that the corruption
      signals can be resampled to the clean sample rate before convolution.
  
  Example
  -------
  >>> import pytest
  >>> from speechbrain.dataio.dataio import read_audio
  >>> signal = read_audio('tests/samples/single-mic/example1.wav')
  >>> clean = signal.unsqueeze(0) # [batch, time, channels]
  >>> reverb = AddReverb('tests/samples/annotation/RIRs.csv',
  ...                     replacements={'rir_folder': 'tests/samples/RIRs'})
  >>> reverbed = reverb(clean)
class_docstr_tok: ["This","class","convolves","an","audio","signal","with","an","impulse","response",".","Arguments","--","--","--","--","-","csv_file",":","str","The","name","of","a","csv","file","containing","the","location","of","the","impulse","response","files",".","sorting",":","str","The","order","to","iterate","the","csv","file",",","from","one","of","the","following","options",":","random",",","original",",","ascending",",","and","descending",".","num_workers",":","int","Number","of","workers","in","the","DataLoader","(","See","PyTorch","DataLoader","docs",")",".","rir_scale_factor",":","float","It","compresses","or","dilates","the","given","impulse","response",".","If","0","<","scale_factor","<","1",",","the","impulse","response","is","compressed","(","less","reverb",")",",","while","if","scale_factor",">","1","it","is","dilated","(","more","reverb",")",".","replacements",":","dict","A","set","of","string","replacements","to","carry","out","in","the","csv","file",".","Each","time","a","key","is","found","in","the","text",",","it","will","be","replaced","with","the","corresponding","value",".","reverb_sample_rate",":","int","The","sample","rate","of","the","corruption","signals","(","rirs",")",",","so","that","they","can","be","resampled","to","clean","sample","rate","if","necessary",".","clean_sample_rate",":","int","The","sample","rate","of","the","clean","signals",",","so","that","the","corruption","signals","can","be","resampled","to","the","clean","sample","rate","before","convolution",".","Example","--","--","--","-",">",">",">","import","pytest",">",">",">","from","speechbrain.dataio.dataio","import","read_audio",">",">",">","signal","=","read_audio","(","'tests\/samples\/single-mic\/example1.wav","'",")",">",">",">","clean","=","signal.unsqueeze","(","0",")","#","[","batch",",","time",",","channels","]",">",">",">","reverb","=","AddReverb","(","'tests\/samples\/annotation\/RIRs.csv","'",",","...","replacements=","{","'rir_folder","'",":","'tests\/samples\/RIRs","'","}",")",">",">",">","reverbed","=","reverb","(","clean",")"]
code: def _load_rir(self, waveforms):
      # Create a data loader for the RIR waveforms
      if not hasattr(self, "data_loader"):
          dataset = ExtendedCSVDataset(
              csvpath=self.csv_file,
              sorting=self.sorting
              if self.sorting != "random"
              else "original",
              replacements=self.replacements,
          )
          self.data_loader = make_dataloader(
              dataset,
              shuffle=(self.sorting == "random"),
              num_workers=self.num_workers,
          )
          self.rir_data = iter(self.data_loader)
  
      try:
          rir_waveform, length = next(self.rir_data).at_position(0)
      except StopIteration:
          self.rir_data = iter(self.data_loader)
          rir_waveform, length = next(self.rir_data).at_position(0)
  
      # Make sure RIR has correct channels
      if len(rir_waveform.shape) == 2:
          rir_waveform = rir_waveform.unsqueeze(-1)
  
      # Make sure RIR has correct type and device
      rir_waveform = rir_waveform.type(waveforms.dtype)
      return rir_waveform.to(waveforms.device)
  
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 3 for calling the AddReverb obj's underlying member method code with example usage: obj._load_rir(waveforms) and returns: rir_waveform