code: def brute_force_neighbors(X, Y, k, metric, **kwargs):
      from sklearn.metrics import DistanceMetric
  
      X, Y = check_array(X), check_array(Y)
      D = DistanceMetric.get_metric(metric, **kwargs).pairwise(Y, X)
      ind = np.argsort(D, axis=1)[:, :k]
      dist = D[np.arange(Y.shape[0])[:, None], ind]
      return dist, ind
  
file_path: scikit-learn/sklearn/neighbors/tests/test_ball_tree.py
imports: import itertools
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_equal
  from sklearn.neighbors._ball_tree import BallTree, BallTree32, BallTree64
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import _convert_container
  from sklearn.utils.validation import check_array
label_desc: Use image node_id 1 for calling a global function with example usage: brute_force_neighbors(X, Y, k, metric) and returns: dist,  ind