code: def test_get_lone_query_labels_custom(self):
      def fn1(x, y):
          return abs(x - y) < 2
  
      def fn2(x, y):
          return abs(x - y) > 99
  
      query_labels = torch.tensor(
          [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100], device=TEST_DEVICE
      )
  
      for comparison_fn in [fn1, fn2]:
          correct_unique_labels = torch.tensor(
              [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100], device=TEST_DEVICE
          )
  
          if comparison_fn is fn1:
              correct_counts = torch.tensor(
                  [3, 4, 3, 3, 3, 3, 3, 3, 3, 2, 1], device=TEST_DEVICE
              )
              correct_lone_query_labels = torch.tensor(
                  [100], device=TEST_DEVICE
              )
              correct_not_lone_query_mask = torch.tensor(
                  [
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      True,
                      False,
                  ],
                  device=TEST_DEVICE,
              )
          elif comparison_fn is fn2:
              correct_counts = torch.tensor(
                  [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], device=TEST_DEVICE
              )
              correct_lone_query_labels = torch.tensor(
                  [1, 2, 3, 4, 5, 6, 7, 8, 9], device=TEST_DEVICE
              )
              correct_not_lone_query_mask = torch.tensor(
                  [
                      True,
                      True,
                      False,
                      False,
                      False,
                      False,
                      False,
                      False,
                      False,
                      False,
                      False,
                      True,
                  ],
                  device=TEST_DEVICE,
              )
  
          label_counts = accuracy_calculator.get_label_match_counts(
              query_labels,
              query_labels,
              comparison_fn,
          )
          unique_labels, counts = label_counts
  
          self.assertTrue(
              torch.all(unique_labels == correct_unique_labels)
          )
          self.assertTrue(torch.all(counts == correct_counts))
  
          (
              lone_query_labels,
              not_lone_query_mask,
          ) = accuracy_calculator.get_lone_query_labels(
              query_labels, label_counts, True, comparison_fn
          )
  
          self.assertTrue(
              torch.all(lone_query_labels == correct_lone_query_labels)
          )
          self.assertTrue(
              torch.all(
                  not_lone_query_mask == correct_not_lone_query_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 7 for calling the TestCalculateAccuracies obj's underlying member method code with example usage: obj.test_get_lone_query_labels_custom() and returns: unknown, unknown