code: def test_ref_mining(self):
      for dtype in TEST_DTYPES:
          batch_size = 32
          pair_miner = PairMarginMiner(pos_margin=0, neg_margin=1)
          triplet_miner = TripletMarginMiner(margin=1)
          self.loss = CrossBatchMemory(
              loss=ContrastiveLoss(),
              embedding_size=self.embedding_size,
              memory_size=self.memory_size,
          )
          for i in range(30):
              embeddings = (
                  torch.randn(batch_size, self.embedding_size)
                  .to(TEST_DEVICE)
                  .type(dtype)
              )
              labels = torch.arange(batch_size).to(TEST_DEVICE)
              self.loss(embeddings, labels)
  
              a1, p, a2, n = lmu.get_all_pairs_indices(
                  labels, self.loss.label_memory
              )
              self.assertTrue(
                  not torch.any(
                      (labels[a1] - self.loss.label_memory[p]).bool()
                  )
              )
              self.assertTrue(
                  torch.all(
                      (labels[a2] - self.loss.label_memory[n]).bool()
                  )
              )
  
              a1, p, a2, n = pair_miner(
                  embeddings,
                  labels,
                  self.loss.embedding_memory,
                  self.loss.label_memory,
              )
              self.assertTrue(
                  not torch.any(
                      (labels[a1] - self.loss.label_memory[p]).bool()
                  )
              )
              self.assertTrue(
                  torch.all(
                      (labels[a2] - self.loss.label_memory[n]).bool()
                  )
              )
  
              a, p, n = triplet_miner(
                  embeddings,
                  labels,
                  self.loss.embedding_memory,
                  self.loss.label_memory,
              )
              self.assertTrue(
                  not torch.any(
                      (labels[a] - self.loss.label_memory[p]).bool()
                  )
              )
              self.assertTrue(
                  torch.all(
                      (labels[a] - self.loss.label_memory[n]).bool()
                  )
              )
  
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 8 for calling the TestCrossBatchMemory obj's underlying member method code with example usage: obj.test_ref_mining() without return types