KNeighborsRegressor with a callable weights stopped working with numpy 1.22.2

### Describe the bug

When you use a callable for the weights param you get:

AttributeError: 'list' object has no attribute 'shape'

`neigh = KNeighborsRegressor(n_neighbors=5, algorithm='brute', metric=euclidean_distance, weights=weights_p2)`

### Steps/Code to Reproduce

```
import numpy as np
from sklearn import neighbors
from sklearn.neighbors import KNeighborsRegressor


x = [5, 6, 4, 3, 4, 3, 1]
y = [2, 5, 2, 3, 7, 6, 8]
g = [4, 3, 3, 3, 2, 2, 1]

D = []
for i in range(len(x)):
    D.append([x[i],y[i]])

def _weights(dist):
    print(dist)
    
    n = len(dist[0])
    w = list()
    d = dist[0]
    
    for i in range(n):
        if d[i] <= 0.0000:
            print("DIV by 0")
            w = [0]*n
            w[i] = 1.0
            print("Weights: ", end='')
            print(w)
            return [w]
        else:
            w.append((1/d[i])**2)
            
    print("   Weights: ", end='')
    print(w)
        
    return [w]



neigh = KNeighborsRegressor(n_neighbors=5, algorithm='brute', metric=euclidean_distance, weights=_weights)
neigh.fit(D, g)
print(neigh.predict([[2, 4]]))
```

Change the weights to `weights='uniform'` (no callable) it will work with numpy 1.22 but with the callable weights I need to downgrade to 1.19.5

### Expected Results

[[1.41421356 2.23606798 2.82842712 3.60555128 3.60555128]]
   Weights: [0.4999999999999999, 0.19999999999999998, 0.12499999999999997, 0.07692307692307693, 0.07692307692307693]
[2.7956778]

### Actual Results

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [54], in <cell line: 8>()
      6 neigh.fit(D, g)
      7 print("Expected GPA: ", end='')
----> 8 print(round(neigh.predict([[2, 4]])[0], 4))
      9 print()

File ~/opt/anaconda3/envs/tensorflow-3/lib/python3.10/site-packages/sklearn/neighbors/_regression.py:240, in KNeighborsRegressor.predict(self, X)
    238     y_pred = np.mean(_y[neigh_ind], axis=1)
    239 else:
--> 240     y_pred = np.empty((X.shape[0], _y.shape[1]), dtype=np.float64)
    241     denom = np.sum(weights, axis=1)
    243     for j in range(_y.shape[1]):

AttributeError: 'list' object has no attribute 'shape'


### Versions

```shell
/Users/ray/opt/anaconda3/envs/tensorflow-3/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")

System:
    python: 3.10.2 | packaged by conda-forge | (main, Feb  1 2022, 19:30:18) [Clang 11.1.0 ]
executable: /Users/ray/opt/anaconda3/envs/tensorflow-3/bin/python3.10
   machine: macOS-12.2.1-x86_64-i386-64bit

Python dependencies:
          pip: 22.0.3
   setuptools: 60.9.3
      sklearn: 1.0.2
        numpy: 1.22.2
        scipy: 1.8.0
       Cython: None
       pandas: 1.4.1
   matplotlib: None
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```

COMMENT:
Got a solution brewing in #22687 if anyone is interested.

Labels: Bug, module:neighbors