class_docstr: Class that manages the training loop. See speechbrain.core.Brain.
class_docstr_tok: ["Class","that","manages","the","training","loop",".","See","speechbrain.core.Brain","."]
docstr: Runs all the computation of the CTC + seq2seq ASR. It returns the
  posterior probabilities of the CTC and seq2seq networks.
  
  Arguments
  ---------
  batch : PaddedBatch
      This batch object contains all the relevant tensors for computation.
  stage : sb.Stage
      One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
  
  Returns
  -------
  predictions : dict
      At training time it returns predicted seq2seq log probabilities.
      If needed it also returns the ctc output log probabilities.
      At validation/test time, it returns the predicted tokens as well.
docstr_tok: ["Runs","all","the","computation","of","the","CTC","+","seq2seq","ASR",".","It","returns","the","posterior","probabilities","of","the","CTC","and","seq2seq","networks",".","Arguments","--","--","--","--","-","batch",":","PaddedBatch","This","batch","object","contains","all","the","relevant","tensors","for","computation",".","stage",":","sb.Stage","One","of","sb.Stage.TRAIN",",","sb.Stage.VALID",",","or","sb.Stage.TEST",".","Returns","--","--","--","-","predictions",":","dict","At","training","time","it","returns","predicted","seq2seq","log","probabilities",".","If","needed","it","also","returns","the","ctc","output","log","probabilities",".","At","validation\/test","time",",","it","returns","the","predicted","tokens","as","well","."]
code: def compute_forward(self, batch, stage):
      """Runs all the computation of the CTC + seq2seq ASR. It returns the
      posterior probabilities of the CTC and seq2seq networks.
  
      Arguments
      ---------
      batch : PaddedBatch
          This batch object contains all the relevant tensors for computation.
      stage : sb.Stage
          One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
  
      Returns
      -------
      predictions : dict
          At training time it returns predicted seq2seq log probabilities.
          If needed it also returns the ctc output log probabilities.
          At validation/test time, it returns the predicted tokens as well.
      """
      # We first move the batch to the appropriate device.
      batch = batch.to(self.device)
      feats, self.feat_lens = self.prepare_features(stage, batch.sig)
      tokens_bos, _ = self.prepare_tokens(stage, batch.tokens_bos)
  
      # Running the encoder (prevent propagation to feature extraction)
      encoded_signal = self.modules.encoder(feats.detach())
  
      # Embed tokens and pass tokens & encoded signal to decoder
      embedded_tokens = self.modules.embedding(tokens_bos)
      decoder_outputs, _ = self.modules.decoder(
          embedded_tokens, encoded_signal, self.feat_lens
      )
  
      # Output layer for seq2seq log-probabilities
      logits = self.modules.seq_lin(decoder_outputs)
      predictions = {"seq_logprobs": self.hparams.log_softmax(logits)}
  
      if self.is_ctc_active(stage):
          # Output layer for ctc log-probabilities
          ctc_logits = self.modules.ctc_lin(encoded_signal)
          predictions["ctc_logprobs"] = self.hparams.log_softmax(
              ctc_logits
          )
      elif stage == sb.Stage.VALID:
          predictions["tokens"], _ = self.hparams.valid_search(
              encoded_signal, self.feat_lens
          )
      elif stage == sb.Stage.TEST:
          predictions["tokens"], _ = self.hparams.test_search(
              encoded_signal, self.feat_lens
          )
  
      return predictions
  
file_path: orion/examples/speechbrain_tutorial/train.py
imports: import logging
  import sys
  import speechbrain
  import torch
  from hyperpyyaml import load_hyperpyyaml
  from mini_librispeech_prepare import prepare_mini_librispeech
  from speechbrain.utils.distributed import run_on_main
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: predictions