class_docstr: SpeechEncoder encodes speech into streams of (pseudo-)units, unit durations,
  and, optionally, F0.
class_docstr_tok: ["SpeechEncoder","encodes","speech","into","streams","of","(","pseudo-",")","units",",","unit","durations",",","and",",","optionally",",","F0","."]
docstr: Takes a waveform and input rate and resamples it into the
  sample rate expected by the encoder (and underlying dense model). Does nothing
  if the sample rates coincide.
  Args:
      waveform (torch.Tensor): audio stream
      input_sample_rate (int): sample rate of the original audio
  
  Returns:
      torch.Tensor: audio, potentially resampled to match the expected
      sample rate of the encoder
docstr_tok: ["Takes","a","waveform","and","input","rate","and","resamples","it","into","the","sample","rate","expected","by","the","encoder","(","and","underlying","dense","model",")",".","Does","nothing","if","the","sample","rates","coincide",".","Args",":","waveform","(","torch.Tensor",")",":","audio","stream","input_sample_rate","(","int",")",":","sample","rate","of","the","original","audio","Returns",":","torch.Tensor",":","audio",",","potentially","resampled","to","match","the","expected","sample","rate","of","the","encoder"]
code: def maybe_resample(
      self, waveform: torch.Tensor, input_sample_rate: int
  ) -> torch.Tensor:
      """
      Takes a waveform and input rate and resamples it into the
      sample rate expected by the encoder (and underlying dense model). Does nothing
      if the sample rates coincide.
      Args:
          waveform (torch.Tensor): audio stream
          input_sample_rate (int): sample rate of the original audio
  
      Returns:
          torch.Tensor: audio, potentially resampled to match the expected
          sample rate of the encoder
      """
      if input_sample_rate == self.expected_sample_rate:
          return waveform
      return torchaudio.functional.resample(
          waveform, input_sample_rate, self.expected_sample_rate
      )
  
file_path: textlesslib/textless/data/speech_encoder.py
imports: import torch
  import torch.nn
  import torchaudio
  from typing import Optional, Callable, Dict
  from textless import dispatch_dense_model, dispatch_quantizer
  from textless import dispatch_dense_model
  from textless.data.f0_preprocess import get_f0, align_f0_to_durations, F0_FRAME_SPACE
  from .collater_utils import wrap_bos_eos
label_desc: Use image node_id 8 for calling the SpeechEncoder obj's underlying member method code with example usage: obj.maybe_resample(waveform, input_sample_rate) and returns: torchaudio, waveform