code: def test_intrinsic_and_context_losses(self):
      torch.manual_seed(24)
      for dtype in TEST_DTYPES:
          if dtype == torch.float16:
              continue
          batch_size, embedding_size = 32, 128
          n_proxies = 3
  
          embeddings = torch.randn(
              batch_size,
              embedding_size,
              device=TEST_DEVICE,
              dtype=dtype,
              requires_grad=True,
          )
          labels = torch.randint(
              0, n_proxies, size=(batch_size,), device=TEST_DEVICE
          )
          proxies = nn.Parameter(
              torch.randn(
                  n_proxies,
                  embedding_size,
                  device=TEST_DEVICE,
                  dtype=dtype,
              )
          )
          alpha = 0.99
  
          original_loss_func = OriginalImplementationManifoldLoss(
              proxies, alpha=alpha, lambdaC=0
          )
          original_loss = original_loss_func(embeddings, labels)
  
          self.assertRaises(
              ValueError,
              lambda: ManifoldLoss(l=embedding_size, lambdaC=-999),
          )
          self.assertRaises(
              AssertionError, loss_incorrect_descriptors_dim
          )
  
          loss_func = ManifoldLoss(
              l=embedding_size,
              K=n_proxies,
              alpha=alpha,
              lambdaC=0,
              margin=0.0,
          )
          loss_func.proxies.data = (
              proxies.data
          )  # In order to have same initializations
          loss = loss_func(embeddings, indices_tuple=labels)
          loss.backward()
  
          rtol = 1e-2 if dtype == torch.float16 else 1e-5
          self.assertTrue(torch.isclose(original_loss, loss, rtol=rtol))
  
file_path: pytorch-metric-learning/tests/losses/test_manifold_loss.py
imports: import unittest
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.module import Module
  from pytorch_metric_learning.losses import ManifoldLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
label_desc: Use image node_id 1 for calling the TestManifoldLoss obj's underlying member method code with example usage: obj.test_intrinsic_and_context_losses() without return types