docstr: Forward computations from the waveform batches to the output probabilities.
docstr_tok: ["Forward","computations","from","the","waveform","batches","to","the","output","probabilities","."]
code: def compute_forward(self, batch, stage):
      """Forward computations from the waveform batches to the output probabilities."""
      batch = batch.to(self.device)
      wavs, wav_lens = batch.sig
      wavs, wav_lens = wavs.to(self.device), wav_lens.to(self.device)
  
      # Downsample the inputs if specified
      if hasattr(self.modules, "downsampler"):
          wavs = self.modules.downsampler(wavs)
  
      # Add waveform augmentation if specified.
      if stage == sb.Stage.TRAIN and hasattr(
          self.hparams, "wav_augment"
      ):
          wavs, wav_lens = self.hparams.wav_augment(wavs, wav_lens)
  
      # Forward pass
  
      # Handling SpeechBrain vs HuggingFance pretrained models
      if hasattr(
          self.modules, "extractor"
      ):  # SpeechBrain pretrained model
          latents = self.modules.extractor(wavs)
          feats = self.modules.encoder_wrapper(
              latents, wav_lens=wav_lens
          )["embeddings"]
      else:  # HuggingFace pretrained model
          feats = self.modules.wav2vec2(wavs, wav_lens)
  
      x = self.modules.enc(feats)
  
      # Compute outputs
      p_tokens = None
      logits = self.modules.ctc_lin(x)
  
      # Upsample the inputs if they have been highly downsampled
      if (
          hasattr(self.hparams, "upsampling")
          and self.hparams.upsampling
      ):
          logits = logits.view(
              logits.shape[0], -1, self.hparams.output_neurons
          )
  
      p_ctc = self.hparams.log_softmax(logits)
  
      if stage == sb.Stage.VALID:
          p_tokens = sb.decoders.ctc_greedy_decode(
              p_ctc, wav_lens, blank_id=self.hparams.blank_index
          )
      elif stage == sb.Stage.TEST:
          p_tokens = test_searcher(p_ctc, wav_lens)
  
          candidates = []
          scores = []
  
          for batch in p_tokens:
              candidates.append([hyp.text for hyp in batch])
              scores.append([hyp.score for hyp in batch])
  
          if hasattr(self.hparams, "rescorer"):
              p_tokens, _ = self.hparams.rescorer.rescore(
                  candidates, scores
              )
  
      return p_ctc, wav_lens, p_tokens
  
file_path: speechbrain/recipes/LibriSpeech/ASR/CTC/train_with_wav2vec.py
imports: import os
  import sys
  import torch
  import logging
  import speechbrain
  from speechbrain.utils.distributed import run_on_main, if_main_process
  from hyperpyyaml import load_hyperpyyaml
  from pathlib import Path
label_desc: Use image node_id 1 for calling the ASR obj's underlying member method code with example usage: obj.compute_forward(batch, stage) and returns: p_ctc,  wav_lens,  p_tokens