code: def test_binary_check(binary_data, metric):
      dist_matrix = pairwise_distances(binary_data, metric=metric)
      if metric in ("jaccard", "dice", "sokalsneath", "yule"):
          dist_matrix[np.where(~np.isfinite(dist_matrix))] = 0.0
      if metric == "russellrao":
          dist_matrix[np.where(~np.isfinite(dist_matrix))] = 0.0
          # And because distance between all zero vectors should be zero
          dist_matrix[10, 11] = 0.0
          dist_matrix[11, 10] = 0.0
      dist_function = dist.named_distances[metric]
      test_matrix = np.array(
          [
              [
                  dist_function(binary_data[i], binary_data[j])
                  for j in range(binary_data.shape[0])
              ]
              for i in range(binary_data.shape[0])
          ]
      )
      assert_array_almost_equal(
          test_matrix,
          dist_matrix,
          err_msg="Distances don't match for metric {}".format(metric),
      )
  
imports: import pytest
  import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal
  import pynndescent.distances
  import pynndescent.sparse
  from scipy import stats
  from scipy.sparse import csr_matrix
  from scipy.version import full_version
  from sklearn.metrics import pairwise_distances
  from sklearn.neighbors import BallTree
  from sklearn.preprocessing import normalize
label_desc: Use image node_id 2 for calling a global function with example usage: test_binary_check(binary_data, metric) without return types