code: def test_loss(self):
      for dtype in TEST_DTYPES:
          num_labels = 10
          num_iter = 10
          batch_size = 32
          for inner_loss in [ContrastiveLoss(), MultiSimilarityLoss()]:
              inner_miner = MultiSimilarityMiner(0.3)
              outer_miner = MultiSimilarityMiner(0.2)
              self.loss = CrossBatchMemory(
                  loss=inner_loss,
                  embedding_size=self.embedding_size,
                  memory_size=self.memory_size,
              )
              self.loss_with_miner = CrossBatchMemory(
                  loss=inner_loss,
                  miner=inner_miner,
                  embedding_size=self.embedding_size,
                  memory_size=self.memory_size,
              )
              self.loss_with_miner2 = CrossBatchMemory(
                  loss=inner_loss,
                  miner=inner_miner,
                  embedding_size=self.embedding_size,
                  memory_size=self.memory_size,
              )
              all_embeddings = torch.tensor([], dtype=dtype).to(
                  TEST_DEVICE
              )
              all_labels = torch.LongTensor([]).to(TEST_DEVICE)
              for i in range(num_iter):
                  embeddings = (
                      torch.randn(batch_size, self.embedding_size)
                      .to(TEST_DEVICE)
                      .type(dtype)
                  )
                  labels = torch.randint(
                      0, num_labels, (batch_size,)
                  ).to(TEST_DEVICE)
                  loss = self.loss(embeddings, labels)
                  loss_with_miner = self.loss_with_miner(
                      embeddings, labels
                  )
                  oa1, op, oa2, on = outer_miner(embeddings, labels)
                  loss_with_miner_and_input_indices = (
                      self.loss_with_miner2(
                          embeddings, labels, (oa1, op, oa2, on)
                      )
                  )
                  all_embeddings = torch.cat(
                      [all_embeddings, embeddings]
                  )
                  all_labels = torch.cat([all_labels, labels])
  
                  # loss with no inner miner
                  indices_tuple = lmu.get_all_pairs_indices(
                      labels, all_labels
                  )
                  a1, p, a2, n = lmu.remove_self_comparisons(
                      indices_tuple,
                      self.loss.curr_batch_idx,
                      self.loss.memory_size,
                  )
                  correct_loss = inner_loss(
                      embeddings,
                      labels,
                      (a1, p, a2, n),
                      all_embeddings,
                      all_labels,
                  )
                  self.assertTrue(torch.isclose(loss, correct_loss))
  
                  # loss with inner miner
                  indices_tuple = inner_miner(
                      embeddings, labels, all_embeddings, all_labels
                  )
                  a1, p, a2, n = lmu.remove_self_comparisons(
                      indices_tuple,
                      self.loss_with_miner.curr_batch_idx,
                      self.loss_with_miner.memory_size,
                  )
                  correct_loss_with_miner = inner_loss(
                      embeddings,
                      labels,
                      (a1, p, a2, n),
                      all_embeddings,
                      all_labels,
                  )
                  self.assertTrue(
                      torch.isclose(
                          loss_with_miner, correct_loss_with_miner
                      )
                  )
  
                  # loss with inner and outer miner
                  indices_tuple = inner_miner(
                      embeddings, labels, all_embeddings, all_labels
                  )
                  a1, p, a2, n = lmu.remove_self_comparisons(
                      indices_tuple,
                      self.loss_with_miner2.curr_batch_idx,
                      self.loss_with_miner2.memory_size,
                  )
                  a1 = torch.cat([oa1, a1])
                  p = torch.cat([op, p])
                  a2 = torch.cat([oa2, a2])
                  n = torch.cat([on, n])
                  correct_loss_with_miner_and_input_indice = inner_loss(
                      embeddings,
                      labels,
                      (a1, p, a2, n),
                      all_embeddings,
                      all_labels,
                  )
                  self.assertTrue(
                      torch.isclose(
                          loss_with_miner_and_input_indices,
                          correct_loss_with_miner_and_input_indice,
                      )
                  )
  
imports: import unittest
  import torch
  import pytorch_metric_learning.losses
  from pytorch_metric_learning.losses import ContrastiveLoss, CrossBatchMemory, MultiSimilarityLoss, NTXentLoss
  from pytorch_metric_learning.miners import DistanceWeightedMiner, MultiSimilarityMiner, PairMarginMiner, TripletMarginMiner
  from pytorch_metric_learning.utils import loss_and_miner_utils
  from ..None import TEST_DEVICE, TEST_DTYPES
  from ..zzz_testing_utils.testing_utils import angle_to_coord
label_desc: Use image node_id 6 for calling the TestCrossBatchMemory obj's underlying member method code with example usage: obj.test_loss() without return types