code: def speed_perturb(waveform, sample_rate: int, factor: float):
      """Speed perturbation which also changes the pitch.
  
      Note: This function should be used with caution as it changes the signal duration.
  
      Args:
          waveform (torch.Tensor): audio signal (..., time)
          sample_rate (int): sampling rate in Hz
          factor (float): speed factor (e.g., 0.9 for 90% speed)
          lengths (torch.Tensor): lengths of the input signals
  
      Returns:
          ret (torch.Tensor): perturbed signal (..., time)
      """
      orig_freq = sample_rate
      source_sample_rate = int(factor * orig_freq)
      target_sample_rate = int(orig_freq)
  
      gcd = math.gcd(source_sample_rate, target_sample_rate)
      source_sample_rate = source_sample_rate // gcd
      target_sample_rate = target_sample_rate // gcd
  
      ret = torchaudio.functional.resample(
          waveform, source_sample_rate, target_sample_rate
      )
      return ret
  
imports: import math
  import random
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torchaudio
label_desc: Use image node_id 9 for calling a global function with example usage: speed_perturb(waveform, sample_rate, factor) and returns: ret