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
      bos_tokens, bos_tokens_lens = 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)
          bos_tokens = self.hparams.wav_augment.replicate_labels(
              bos_tokens
          )
          bos_tokens_lens = self.hparams.wav_augment.replicate_labels(
              bos_tokens_lens
          )
  
      # We compute the padding mask and replace the values with the pad_token_id
      # that the Whisper decoder expect to see.
      abs_tokens_lens = (bos_tokens_lens * bos_tokens.shape[1]).long()
      pad_mask = (
          torch.arange(abs_tokens_lens.max(), device=self.device)[
              None, :
          ]
          < abs_tokens_lens[:, None]
      )
      bos_tokens[~pad_mask] = self.tokenizer.pad_token_id
  
      # Forward encoder + decoder
      enc_out, logits, _ = self.modules.whisper(wavs, bos_tokens)
  
      log_probs = self.hparams.log_softmax(logits)
  
      hyps = None
      if stage == sb.Stage.VALID or stage == sb.Stage.TEST:
          # Decide searcher for inference: valid or test search
          if stage == sb.Stage.VALID:
              hyps, _, _, _ = self.hparams.valid_search(
                  enc_out.detach(), wav_lens
              )
          else:
              hyps, _, _, _ = self.hparams.test_search(
                  enc_out.detach(), wav_lens
              )
  
      return log_probs, hyps, wav_lens
  
file_path: speechbrain/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py
imports: import os
  import sys
  import torch
  import logging
  import speechbrain
  from speechbrain.utils.distributed import run_on_main, if_main_process
  from speechbrain.utils.data_utils import undo_padding
  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: log_probs,  hyps,  wav_lens