code: def get_loss(self, guesses: Floats2d, truths: Floats2d) -> float:
      if guesses.shape != truths.shape:  # pragma: no cover
          err = f"Cannot calculate cosine similarity: mismatched shapes: {guesses.shape} vs {truths.shape}."
          raise ValueError(err)
  
      xp = get_array_module(guesses)
      cosine = self.get_similarity(guesses, truths)
      losses = xp.abs(cosine - 1)
      if self.ignore_zeros:
          # If the target was a zero vector, don't count it in the loss.
          zero_indices = xp.abs(truths).sum(axis=1) == 0
          losses[zero_indices] = 0
      if self.normalize:
          losses = losses / guesses.shape[0]
      loss = losses.sum()
      return loss
  
imports: from abc import abstractmethod
  from typing import Any, Dict, Generic, List, Optional, Sequence, Tuple, TypeVar, Union, cast
  from .config import registry
  from .types import Floats2d, Ints1d
  from .util import get_array_module, to_categorical
label_desc: Use image node_id 5 for calling the CosineDistance obj's underlying member method code with example usage: obj.get_loss(guesses, truths) and returns: loss