docstr: Adds speed perturbation and random_shift to the input signals
docstr_tok: ["Adds","speed","perturbation","and","random_shift","to","the","input","signals"]
code: def add_speed_perturb(self, targets, targ_lens):
      """Adds speed perturbation and random_shift to the input signals"""
  
      min_len = -1
      recombine = False
  
      if self.hparams.use_speedperturb:
          # Performing speed change (independently on each source)
          new_targets = []
          recombine = True
  
          for i in range(targets.shape[-1]):
              new_target = self.hparams.speed_perturb(
                  targets[:, :, i],
              )
              new_targets.append(new_target)
              if i == 0:
                  min_len = new_target.shape[-1]
              else:
                  if new_target.shape[-1] < min_len:
                      min_len = new_target.shape[-1]
  
          if self.hparams.use_rand_shift:
              # Performing random_shift (independently on each source)
              recombine = True
              for i in range(targets.shape[-1]):
                  rand_shift = torch.randint(
                      self.hparams.min_shift,
                      self.hparams.max_shift,
                      (1,),
                  )
                  new_targets[i] = new_targets[i].to(self.device)
                  new_targets[i] = torch.roll(
                      new_targets[i], shifts=(rand_shift[0],), dims=1
                  )
  
          # Re-combination
          if recombine:
              if self.hparams.use_speedperturb:
                  targets = torch.zeros(
                      targets.shape[0],
                      min_len,
                      targets.shape[-1],
                      device=targets.device,
                      dtype=torch.float,
                  )
              for i, new_target in enumerate(new_targets):
                  targets[:, :, i] = new_targets[i][:, 0:min_len]
  
      mix = targets.sum(-1)
      return mix, targets
  
imports: import os
  import csv
  import sys
  import torch
  import torchaudio
  import numpy
  from tqdm import tqdm
  import speechbrain
  import torch.nn.functional
  import speechbrain.nnet.schedulers
  from speechbrain.utils.distributed import run_on_main
  from hyperpyyaml import load_hyperpyyaml
  import logging
  from speechbrain.core import AMPConfig
label_desc: Use image node_id 6 for calling the Separation obj's underlying member method code with example usage: obj.add_speed_perturb(targets, targ_lens) and returns: mix,  targets