docstr: Given the network predictions and targets computed the forward loss.
docstr_tok: ["Given","the","network","predictions","and","targets","computed","the","forward","loss","."]
code: def compute_objectives(self, predictions, batch, stage):
      "Given the network predictions and targets computed the forward loss."
      predictions, lens = predictions
      phns, phn_lens = batch.phn_encoded
  
      prev_alignments = self.hparams.aligner.get_prev_alignments(
          batch.id, predictions, lens, phns, phn_lens
      )
      loss = self.hparams.compute_cost(predictions, prev_alignments)
  
      if stage != sb.Stage.TRAIN:
          viterbi_scores, alignments = self.hparams.aligner(
              predictions, lens, phns, phn_lens, "viterbi"
          )
          self.hparams.aligner.store_alignments(batch.id, alignments)
  
      return loss
  
file_path: speechbrain/tests/integration/ASR_alignment_viterbi/example_asr_alignment_viterbi_experiment.py
imports: import pathlib
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 2 for calling the AlignBrain obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss