docstr: Computes the loss given predictions and targets.
docstr_tok: ["Computes","the","loss","given","predictions","and","targets","."]
code: def compute_objectives(self, predictions, batch, stage):
      """Computes the loss given predictions and targets."""
      (
          uttr_embeddings,
          text_embeddings,
      ) = predictions
  
      B, S = uttr_embeddings.shape
      loss = 0.0
      for b in range(B):
          cosine_sim = torch.dot(
              uttr_embeddings[b].float(), text_embeddings[b].float()
          )
          loss += 1.0 - cosine_sim
      loss *= self.hparams.loss_scale
      return loss
  
file_path: speechbrain/recipes/IWSLT22_lowresource/AST/transformer/train_samu.py
imports: import sys
  import torch
  import logging
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain
  import torch.nn.functional
  from speechbrain.utils.distributed import run_on_main
label_desc: Use image node_id 2 for calling the ST obj's underlying member method code with example usage: obj.compute_objectives(predictions, batch, stage) and returns: loss