class_docstr: Class for language ID training"
      
class_docstr_tok: ["Class","for","language","ID","training","''"]
docstr: Computes the loss using speaker-id as label.
          
docstr_tok: ["Computes","the","loss","using","speaker-id","as","label","."]
code: def compute_objectives(self, predictions, batch, stage):
      """Computes the loss using speaker-id as label."""
      predictions, lens = predictions
      uttid = batch.id
      langid = batch.lang_id_encoded
  
      # Concatenate labels (due to data augmentation)
      if stage == sb.Stage.TRAIN and hasattr(
          self.hparams, "wav_augment"
      ):
          langid = self.hparams.wav_augment.replicate_labels(langid)
  
      # breakpoint()
      loss = self.hparams.compute_cost(
          predictions, langid.unsqueeze(1), lens
      )
  
      if hasattr(self.hparams.lr_annealing, "on_batch_end"):
          self.hparams.lr_annealing.on_batch_end(self.optimizer)
  
      if stage != sb.Stage.TRAIN:
          self.error_metrics.append(
              uttid, predictions, langid.unsqueeze(1), lens
          )
  
      return loss
  
file_path: speechbrain/recipes/VoxLingua107/lang_id/train.py
imports: import os
  import sys
  import random
  from typing import Dict
  import json
  from functools import partial
  import webdataset
  import logging
  import torch
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.dataio.batch import PaddedBatch
label_desc: Use image node_id 2 for calling the LanguageBrain obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss