code: def helper(
      self,
      embeddings,
      labels,
      triplets,
      dtype,
      ref_emb=None,
      ref_labels=None,
  ):
      loss_func = AngularLoss(alpha=40)
      loss = loss_func(
          embeddings, labels, ref_emb=ref_emb, ref_labels=ref_labels
      )
      loss.backward()
      sq_tan_alpha = (
          torch.tan(
              torch.tensor(np.radians(40), dtype=dtype).to(TEST_DEVICE)
          )
          ** 2
      )
      correct_losses = [0, 0, 0, 0]
      for a, p, n in triplets:
          anchor = embeddings[a]
          if ref_emb is not None:
              positive, negative = ref_emb[p], ref_emb[n]
          else:
              positive, negative = embeddings[p], embeddings[n]
          exponent = 4 * sq_tan_alpha * torch.matmul(
              anchor + positive, negative
          ) - 2 * (1 + sq_tan_alpha) * torch.matmul(anchor, positive)
          correct_losses[a] += torch.exp(exponent)
      total_loss = 0
      for c in correct_losses:
          total_loss += torch.log(1 + c)
      total_loss /= len(correct_losses)
      self.assertTrue(torch.isclose(loss, total_loss, rtol=1e-2))
  
file_path: pytorch-metric-learning/tests/losses/test_angular_loss.py
imports: import unittest
  import numpy
  import torch
  from pytorch_metric_learning.losses import AngularLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
  from ..zzz_testing_utils.testing_utils import angle_to_coord
  from .utils import get_triplet_embeddings_with_ref
label_desc: Use image node_id 3 for calling the TestAngularLoss obj's underlying member method code with example usage: obj.helper(embeddings, labels, triplets, dtype, ref_emb, ref_labels) without return types