code: def test_sanity_check(self):
      # cross batch memory with batch_size == memory_size should be equivalent to just using the inner loss function
      for dtype in TEST_DTYPES:
          for test_enqueue_mask in [False, True]:
              for memory_size in range(20, 40, 5):
                  inner_loss = NTXentLoss(temperature=0.1)
                  inner_miner = TripletMarginMiner(margin=0.1)
                  loss = CrossBatchMemory(
                      loss=inner_loss,
                      embedding_size=self.embedding_size,
                      memory_size=memory_size,
                  )
                  loss_with_miner = CrossBatchMemory(
                      loss=inner_loss,
                      embedding_size=self.embedding_size,
                      memory_size=memory_size,
                      miner=inner_miner,
                  )
                  for i in range(10):
                      if test_enqueue_mask:
                          enqueue_mask = torch.zeros(
                              memory_size * 2
                          ).bool()
                          enqueue_mask[memory_size:] = True
                          batch_size = memory_size * 2
                      else:
                          enqueue_mask = None
                          batch_size = memory_size
                      embeddings = (
                          torch.randn(batch_size, self.embedding_size)
                          .to(TEST_DEVICE)
                          .type(dtype)
                      )
                      labels = torch.randint(0, 4, (batch_size,)).to(
                          TEST_DEVICE
                      )
  
                      if test_enqueue_mask:
                          not_enqueue_emb = embeddings[~enqueue_mask]
                          not_enqueue_labels = labels[~enqueue_mask]
                          enqueue_emb = embeddings[enqueue_mask]
                          enqueue_labels = labels[enqueue_mask]
  
                      if test_enqueue_mask:
                          pairs = lmu.get_all_pairs_indices(
                              not_enqueue_labels, enqueue_labels
                          )
                          inner_loss_val = inner_loss(
                              not_enqueue_emb,
                              not_enqueue_labels,
                              pairs,
                              enqueue_emb,
                              enqueue_labels,
                          )
                      else:
                          inner_loss_val = inner_loss(
                              embeddings, labels
                          )
                      loss_val = loss(
                          embeddings, labels, enqueue_mask=enqueue_mask
                      )
                      self.assertTrue(
                          torch.isclose(inner_loss_val, loss_val)
                      )
  
                      if test_enqueue_mask:
                          triplets = inner_miner(
                              not_enqueue_emb,
                              not_enqueue_labels,
                              enqueue_emb,
                              enqueue_labels,
                          )
                          inner_loss_val = inner_loss(
                              not_enqueue_emb,
                              not_enqueue_labels,
                              triplets,
                              enqueue_emb,
                              enqueue_labels,
                          )
                      else:
                          triplets = inner_miner(embeddings, labels)
                          inner_loss_val = inner_loss(
                              embeddings, labels, triplets
                          )
                      loss_val = loss_with_miner(
                          embeddings, labels, enqueue_mask=enqueue_mask
                      )
                      self.assertTrue(
                          torch.isclose(inner_loss_val, loss_val)
                      )
  
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 4 for calling the TestCrossBatchMemory obj's underlying member method code with example usage: obj.test_sanity_check() without return types