docstr: Given the network predictions and targets computed the loss.
docstr_tok: ["Given","the","network","predictions","and","targets","computed","the","loss","."]
code: def compute_objectives(self, predictions, batch, stage):
      "Given the network predictions and targets computed the loss."
      ids = batch.id
      phns, phn_lens = batch.phn_encoded
  
      if stage == sb.Stage.TRAIN and hasattr(
          self.hparams, "wav_augment"
      ):
          phns = self.hparams.wav_augment.replicate_labels(phns)
          phn_lens = self.hparams.wav_augment.replicate_labels(phn_lens)
  
      if stage == sb.Stage.TRAIN:
          predictions, wav_lens = predictions
      else:
          predictions, wav_lens, hyps = predictions
  
      # Transducer loss use logits from RNN-T model.
      loss = self.hparams.compute_cost(
          predictions, phns, wav_lens, phn_lens
      )
      self.transducer_metrics.append(
          ids, predictions, phns, wav_lens, phn_lens
      )
  
      if stage != sb.Stage.TRAIN:
          self.per_metrics.append(
              ids,
              hyps,
              phns,
              None,
              phn_lens,
              self.label_encoder.decode_ndim,
          )
  
      return loss
  
file_path: speechbrain/recipes/TIMIT/ASR/transducer/train.py
imports: import os
  import sys
  import logging
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
label_desc: Use image node_id 2 for calling the ASR_Brain obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss