docstr: Computes the loss given the predicted and targeted outputs.
  
  Arguments
  ---------
  inputs : tensors
      The output tensors from `compute_forward`.
  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
  -------
  loss : torch.Tensor
      A one-element tensor used for backpropagating the gradient.
docstr_tok: ["Computes","the","loss","given","the","predicted","and","targeted","outputs",".","Arguments","--","--","--","--","-","inputs",":","tensors","The","output","tensors","from","`","compute_forward","`",".","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","--","--","--","-","loss",":","torch.Tensor","A","one-element","tensor","used","for","backpropagating","the","gradient","."]
code: def compute_objectives(self, inputs, batch, stage):
      """Computes the loss given the predicted and targeted outputs.
  
      Arguments
      ---------
      inputs : tensors
          The output tensors from `compute_forward`.
      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
      -------
      loss : torch.Tensor
          A one-element tensor used for backpropagating the gradient.
      """
  
      predictions, lens = inputs
  
      targets = batch.language_encoded.data
  
      # Concatenate labels (due to data augmentation)
      if stage == sb.Stage.TRAIN:
          if hasattr(self.hparams, "wav_augment"):
              targets = self.hparams.wav_augment.replicate_labels(
                  targets
              )
              if hasattr(self.hparams.lr_annealing, "on_batch_end"):
                  self.hparams.lr_annealing.on_batch_end(self.optimizer)
  
      loss = self.hparams.compute_cost(predictions, targets)
  
      if stage != sb.Stage.TRAIN:
          self.error_metrics.append(
              batch.id, predictions, targets, lens
          )
  
      return loss
  
file_path: speechbrain/recipes/CommonLanguage/lang_id/train.py
imports: import os
  import sys
  import logging
  import torchaudio
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from common_language_prepare import prepare_common_language
label_desc: Use image node_id 3 for calling the LID obj's underlying member method code with example usage: obj.compute_objectives(inputs, batch, stage) and returns: loss