code: def test_get_lone_query_labels_multi_dim(self):
      def equality2D(x, y):
          return (x[..., 0] == y[..., 0]) & (x[..., 1] == y[..., 1])
  
      def custom_label_comparison_fn(x, y):
          return (x[..., 0] == y[..., 0]) & (x[..., 1] != y[..., 1])
  
      query_labels = torch.tensor(
          [
              (1, 3),
              (0, 3),
              (0, 3),
              (0, 3),
              (1, 2),
              (4, 5),
          ],
          device=TEST_DEVICE,
      )
  
      for comparison_fn in [equality2D, custom_label_comparison_fn]:
          label_counts = accuracy_calculator.get_label_match_counts(
              query_labels,
              query_labels,
              comparison_fn,
          )
  
          unique_labels, counts = label_counts
          correct_unique_labels = torch.tensor(
              [[0, 3], [1, 2], [1, 3], [4, 5]], device=TEST_DEVICE
          )
          if comparison_fn is equality2D:
              correct_counts = torch.tensor(
                  [3, 1, 1, 1], device=TEST_DEVICE
              )
          else:
              correct_counts = torch.tensor(
                  [0, 1, 1, 0], device=TEST_DEVICE
              )
  
          self.assertTrue(torch.all(correct_counts == counts))
          self.assertTrue(
              torch.all(correct_unique_labels == unique_labels)
          )
  
          if comparison_fn is equality2D:
              correct = [
                  (
                      True,
                      torch.tensor(
                          [[1, 2], [1, 3], [4, 5]], device=TEST_DEVICE
                      ),
                      torch.tensor(
                          [False, True, True, True, False, False],
                          device=TEST_DEVICE,
                      ),
                  ),
                  (
                      False,
                      torch.tensor([[]], device=TEST_DEVICE),
                      torch.tensor(
                          [True, True, True, True, True, True],
                          device=TEST_DEVICE,
                      ),
                  ),
              ]
          else:
              correct = [
                  (
                      True,
                      torch.tensor(
                          [[0, 3], [4, 5]], device=TEST_DEVICE
                      ),
                      torch.tensor(
                          [True, False, False, False, True, False],
                          device=TEST_DEVICE,
                      ),
                  ),
                  (
                      False,
                      torch.tensor(
                          [[0, 3], [4, 5]], device=TEST_DEVICE
                      ),
                      torch.tensor(
                          [True, False, False, False, True, False],
                          device=TEST_DEVICE,
                      ),
                  ),
              ]
  
          for same_source, correct_lone, correct_mask in correct:
              (
                  lone_query_labels,
                  not_lone_query_mask,
              ) = accuracy_calculator.get_lone_query_labels(
                  query_labels, label_counts, same_source, comparison_fn
              )
              if correct_lone.numel() == 0:
                  self.assertTrue(lone_query_labels.numel() == 0)
              else:
                  self.assertTrue(
                      torch.all(lone_query_labels == correct_lone)
                  )
  
              self.assertTrue(
                  torch.all(not_lone_query_mask == correct_mask)
              )
  
imports: import itertools
  import logging
  import unittest
  import numpy
  import torch
  from pytorch_metric_learning.distances import LpDistance
  from pytorch_metric_learning.utils import accuracy_calculator
  from pytorch_metric_learning.utils.common_functions import LOGGER
  from pytorch_metric_learning.utils.inference import CustomKNN, FaissKMeans, FaissKNN
  from ..None import TEST_DEVICE
label_desc: Use image node_id 8 for calling the TestCalculateAccuracies obj's underlying member method code with example usage: obj.test_get_lone_query_labels_multi_dim() and returns: unknown, unknown