code: def spatial_check(
      metric, spatial_data, spatial_distances, with_grad=False
  ):
      # Check that metric is supported for this test, otherwise, fail!
      assert (
          metric in spatial_distances
      ), f"{metric} not valid for spatial data"
      dist_matrix = pairwise_distances(spatial_data, metric=metric)
      # scipy is bad sometimes
      if metric == "braycurtis":
          dist_matrix[np.where(~np.isfinite(dist_matrix))] = 0.0
  
      if metric in ("cosine", "correlation"):
          dist_matrix[np.where(~np.isfinite(dist_matrix))] = 1.0
          # And because distance between all zero vectors should be zero
          dist_matrix[10, 11] = 0.0
          dist_matrix[11, 10] = 0.0
  
      run_test_metric(
          metric, spatial_data, dist_matrix, with_grad=with_grad
      )
  
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 2 for calling a global function with example usage: spatial_check(metric, spatial_data, spatial_distances, with_grad) without return types