code: def test_fast_ap_loss(self):
      num_bins = 5
      loss_func = FastAPLoss(num_bins)
      original_loss_func = OriginalImplementationFastAPLoss(num_bins)
      ref_emb = torch.randn(32, 32)
      ref_labels = torch.randint(0, 10, (32,))
  
      for dtype in TEST_DTYPES:
          embedding_angles = torch.arange(0, 180)
          embeddings = torch.tensor(
              [angle_to_coord(a) for a in embedding_angles],
              requires_grad=True,
              dtype=dtype,
          ).to(
              TEST_DEVICE
          )  # 2D embeddings
          labels = torch.randint(low=0, high=10, size=(180,)).to(
              TEST_DEVICE
          )
  
          loss = loss_func(embeddings, labels)
          loss.backward()
          original_loss = original_loss_func(
              torch.nn.functional.normalize(embeddings), labels
          )
          rtol = 1e-2 if dtype == torch.float16 else 1e-5
          self.assertTrue(torch.isclose(loss, original_loss, rtol=rtol))
  
          # fastap doesn't support ref_emb
          self.assertRaises(
              ValueError,
              lambda: loss_func(
                  embeddings,
                  labels,
                  ref_emb=ref_emb,
                  ref_labels=ref_labels,
              ),
          )
  
file_path: pytorch-metric-learning/tests/losses/test_fastap_loss.py
imports: import torch
  from torch.autograd import Variable
  import unittest
  from pytorch_metric_learning.losses import FastAPLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
  from ..zzz_testing_utils.testing_utils import angle_to_coord
label_desc: Use image node_id 1 for calling the TestFastAPLoss obj's underlying member method code with example usage: obj.test_fast_ap_loss() without return types