code: def run_test_sparse_metric(metric, sparse_test_data, dist_matrix):
      """Core utility function to run test of target metric on sparse data"""
      dist_function = spdist.sparse_named_distances[metric]
      if metric in spdist.sparse_need_n_features:
          test_matrix = np.array(
              [
                  [
                      dist_function(
                          sparse_test_data[i].indices,
                          sparse_test_data[i].data,
                          sparse_test_data[j].indices,
                          sparse_test_data[j].data,
                          sparse_test_data.shape[1],
                      )
                      for j in range(sparse_test_data.shape[0])
                  ]
                  for i in range(sparse_test_data.shape[0])
              ]
          )
      else:
          test_matrix = np.array(
              [
                  [
                      dist_function(
                          sparse_test_data[i].indices,
                          sparse_test_data[i].data,
                          sparse_test_data[j].indices,
                          sparse_test_data[j].data,
                      )
                      for j in range(sparse_test_data.shape[0])
                  ]
                  for i in range(sparse_test_data.shape[0])
              ]
          )
      assert_array_almost_equal(
          test_matrix,
          dist_matrix,
          err_msg="Sparse distances don't match "
          "for metric {}".format(metric),
      )
  
imports: import numpy
  from numpy.testing import assert_array_almost_equal
  import umap.distances
  import umap.sparse
  from sklearn.metrics import pairwise_distances
  from sklearn.neighbors import BallTree
  from scipy.version import full_version
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: run_test_sparse_metric(metric, sparse_test_data, dist_matrix) without return types