def METHOD_NAME():
    base = np.array([[1.0, 1], [1, 2], [4, 2], [4, 3]])
    query = np.array([[1.0, 1], [2, 2], [4, 4]])
    knn = KNearestNeighbors(2, metric="manhattan", return_distance=True, return_index=True)
    knn.fit(base)
    r = knn.transform(query)
    assert r[0] == pytest.approx(np.array([[0, 1], [1, 0], [3, 2]]))
    assert r[1] == pytest.approx(np.array([[0.0, 1], [1, 2], [1, 2]]))
    knn = KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False)
    knn.fit(base)
    r = knn.transform(query)
    assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
    r = (
        KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False, implementation="keops")
        .fit(base)
        .transform(query)
    )
    assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
    r = (
        KNearestNeighbors(2, metric="chebyshev", return_distance=True, return_index=False, implementation="keops", enable_autodiff=True)
        .fit(base)
        .transform(query)
    )
    assert r == pytest.approx(np.array([[0.0, 1], [1, 1], [1, 2]]))
    knn = KNearestNeighbors(2, metric="minkowski", p=3, return_distance=False, return_index=True)
    knn.fit(base)
    r = knn.transform(query)
    assert np.array_equal(r, [[0, 1], [1, 0], [3, 2]])
    r = (
        KNearestNeighbors(2, metric="minkowski", p=3, return_distance=False, return_index=True, implementation="keops")
        .fit(base)
        .transform(query)
    )
    assert np.array_equal(r, [[0, 1], [1, 0], [3, 2]])
    dist = np.array([[0.0, 3, 8], [1, 0, 5], [1, 2, 0]])
    knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=False)
    r = knn.fit_transform(dist)
    assert np.array_equal(r, [[0, 1], [1, 0], [2, 0]])
    knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=True, sort_results=True)
    r = knn.fit_transform(dist)
    assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]])
    assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]])
    # Second time in parallel
    knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=False, n_jobs=2, sort_results=True)
    r = knn.fit_transform(dist)
    assert np.array_equal(r, [[0, 1], [1, 0], [2, 0]])
    knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=True, n_jobs=2)
    r = knn.fit_transform(dist)
    assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]])
    assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]])