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)
      tokens_bos, _ = batch.tokens_bos
  
      # 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)
          tokens_bos = self.hparams.wav_augment.replicate_labels(
              tokens_bos
          )
  
      # compute features
      feats = self.hparams.compute_features(wavs)
      current_epoch = self.hparams.epoch_counter.current
      feats = self.hparams.normalize(
          feats, wav_lens, epoch=current_epoch
      )
  
      # Add feature augmentation if specified.
      if stage == sb.Stage.TRAIN and hasattr(
          self.hparams, "fea_augment"
      ):
          feats, fea_lens = self.hparams.fea_augment(feats, wav_lens)
          tokens_bos = self.hparams.fea_augment.replicate_labels(
              tokens_bos
          )
  
      # forward modules
      src = self.modules.CNN(feats)
      enc_out, pred = self.modules.Transformer(
          src, tokens_bos, wav_lens, pad_idx=self.hparams.pad_index
      )
  
      # output layer for ctc log-probabilities
      logits = self.modules.ctc_lin(enc_out)
      p_ctc = self.hparams.log_softmax(logits)
  
      # output layer for seq2seq log-probabilities
      pred = self.modules.seq_lin(pred)
      p_seq = self.hparams.log_softmax(pred)
  
      # Compute outputs
      hyps = None
      current_epoch = self.hparams.epoch_counter.current
      is_valid_search = (
          stage == sb.Stage.VALID
          and current_epoch % self.hparams.valid_search_interval == 0
      )
      is_test_search = stage == sb.Stage.TEST
  
      if is_valid_search:
          hyps, _, _, _ = self.hparams.valid_search(
              enc_out.detach(), wav_lens
          )
  
      elif is_test_search:
          hyps, _, _, _ = self.hparams.test_search(
              enc_out.detach(), wav_lens
          )
  
      return p_ctc, p_seq, wav_lens, hyps
  
file_path: speechbrain/recipes/CommonVoice/ASR/transformer/train.py
imports: import sys
  import torch
  import torchaudio
  import logging
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.tokenizers.SentencePiece import SentencePiece
  from speechbrain.utils.distributed import run_on_main, if_main_process
  from speechbrain.utils.data_utils import undo_padding
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,  p_seq,  wav_lens,  hyps