code: def valid_metrics(algo="brute", cuml_algo=None):
      cuml_algo = algo if cuml_algo is None else cuml_algo
      cuml_metrics = cuml.neighbors.VALID_METRICS[cuml_algo]
      sklearn_metrics = sklearn.neighbors.VALID_METRICS[algo]
      ret = [
          value for value in cuml_metrics if value in sklearn_metrics
      ]
      ret.sort()
      ret.remove("haversine")  # This is tested on its own
      return ret
  
imports: import gc
  from cuml.common import has_scipy
  import cuml
  import sklearn
  from cuml.internals.safe_imports import cpu_only_import_from
  from numpy.testing import assert_array_equal, assert_allclose
  from cuml.internals.safe_imports import cpu_only_import
  import pytest
  import math
  from cuml.testing.utils import array_equal, unit_param, quality_param, stress_param
  from cuml.neighbors import NearestNeighbors
  from sklearn.neighbors import NearestNeighbors
  from cuml.datasets import make_blobs
  from sklearn.metrics import pairwise_distances
  from cuml.metrics import pairwise_distances
  from cuml.internals import logger
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 2 for calling a global function with example usage: valid_metrics(algo, cuml_algo) and returns: ret