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."""
      emoid, _ = batch.emo_encoded
  
      if stage == sb.Stage.TEST:
          if self.hparams.use_threshold:
              preds = threshold_tuning(
                  predictions, self.hparams.threshold
              )
          else:
              preds = torch.argmax(predictions, dim=2)
  
          emoid_decoded = label_encoder.decode_ndim(emoid)
          preds_decoded = label_encoder.decode_ndim(preds)
  
          self.load_ZED()
          with open(self.hparams.eder_file, "a") as w:
              for i in range(len(batch.id)):
                  if len(preds_decoded[i]) < len(emoid_decoded[i]):
                      preds_decoded[i].append(preds_decoded[i][-1])
                  eder = EDER(
                      prediction=preds_decoded[i],
                      id=batch.id[i],
                      duration=self.ZED[batch.id[i]]["duration"],
                      emotion=self.ZED[batch.id[i]]["emotion"],
                      window_length=self.hparams.window_length * 0.02,
                      stride=self.hparams.stride * 0.02,
                  )
  
                  w.write("    wav_id : " + batch.id[i] + "\n")
                  w.write(
                      " reference : " + "".join(emoid_decoded[i]) + "\n"
                  )
                  w.write(
                      "prediction : " + "".join(preds_decoded[i]) + "\n"
                  )
                  w.write(
                      " ctc_label : "
                      + "".join(del_adjacent(emoid_decoded[i]))
                      + "\n"
                  )
                  w.write(
                      "  ctc_pred : "
                      + "".join(del_adjacent(preds_decoded[i]))
                      + "\n"
                  )
                  w.write("      EDER : " + str(eder) + "\n")
                  w.write("\n")
  
                  self.eder.append(eder)
  
      loss = self.hparams.compute_cost(predictions, emoid)
      if stage != sb.Stage.TRAIN:
          self.error_metrics.append(batch.id, predictions, emoid)
  
      return loss
  
file_path: speechbrain/recipes/ZaionEmotionDataset/emotion_diarization/train.py
imports: import os
  import sys
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  import torch
  import json
  import itertools
  from speechbrain.utils.EDER import EDER
label_desc: Use image node_id 2 for calling the EmoDiaBrain obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss