code: def speed(
      waveform: torch.Tensor,
      orig_freq: int,
      factor: float,
      lengths: Optional[torch.Tensor] = None,
  ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:
      r"""Adjusts waveform speed.
  
      .. devices:: CPU CUDA
  
      .. properties:: Autograd TorchScript
  
      Args:
          waveform (torch.Tensor): Input signals, with shape `(..., time)`.
          orig_freq (int): Original frequency of the signals in ``waveform``.
          factor (float): Factor by which to adjust speed of input. Values greater than 1.0
              compress ``waveform`` in time, whereas values less than 1.0 stretch ``waveform`` in time.
          lengths (torch.Tensor or None, optional): Valid lengths of signals in ``waveform``, with shape `(...)`.
              If ``None``, all elements in ``waveform`` are treated as valid. (Default: ``None``)
  
      Returns:
          (torch.Tensor, torch.Tensor or None):
              torch.Tensor
                  Speed-adjusted waveform, with shape `(..., new_time).`
              torch.Tensor or None
                  If ``lengths`` is not ``None``, valid lengths of signals in speed-adjusted waveform,
                  with shape `(...)`; otherwise, ``None``.
      """
  
      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
  
      if lengths is None:
          out_lengths = None
      else:
          out_lengths = torch.ceil(
              lengths * target_sample_rate / source_sample_rate
          ).to(lengths.dtype)
  
      return (
          resample(waveform, source_sample_rate, target_sample_rate),
          out_lengths,
      )
  
imports: import math
  import tempfile
  import warnings
  from collections.abc import Sequence
  from typing import List, Optional, Tuple, Union
  import torch
  import torchaudio
  from torch import Tensor
  from torchaudio._internal.module_utils import deprecated
  from .filtering import highpass_biquad, treble_biquad
label_desc: Use image node_id 53 for calling a global function with example usage: speed(waveform, orig_freq, factor, lengths) and returns: resample,  out_lengths