class_docstr: Class for GSC training"
      
class_docstr_tok: ["Class","for","GSC","training","''"]
docstr: Computes the loss using command-id as label.
          
docstr_tok: ["Computes","the","loss","using","command-id","as","label","."]
code: def compute_objectives(self, predictions, batch, stage):
      """Computes the loss using command-id as label."""
      predictions, lens = predictions
      uttid = batch.id
      command, _ = batch.command_encoded
  
      # Concatenate labels (due to data augmentation)
      if stage == sb.Stage.TRAIN and hasattr(
          self.hparams, "wav_augment"
      ):
          command = self.hparams.wav_augment.replicate_labels(command)
  
      # compute the cost function
      loss = self.hparams.compute_cost(predictions, command, lens)
      # loss = sb.nnet.losses.nll_loss(predictions, command, 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, command, lens)
  
      return loss
  
file_path: speechbrain/recipes/Google-speech-commands/train.py
imports: import os
  import sys
  import torch
  import torchaudio
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain.nnet.CNN
  from speechbrain.utils.distributed import run_on_main
label_desc: Use image node_id 2 for calling the SpeakerBrain obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss