"NameError: name 'functools' is not defined" running `fit` method for a GridSearchCV class

### Describe the bug

I upgraded scikit-learn to latest version yesterday and rerunning an ElasticNet demo I'm getting a puzzling error message.  This code works without issue in a Jupyter notebook I had saved from months ago.    

Working within Spyder 5.3.3, Python 3.9 and with scikit-learn v1.4.1.post1, I get the below error when running the code included.  

Many thanks for anyone that can shed some light. 

### Steps/Code to Reproduce

  
```
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.linear_model import ElasticNet

x = np.array([[0.26,0.02309,0.555556,0.625,0.449275,0,0,0,0,0.349315,0.254523,0.138267,0,0.338346,0.203283,0,0,0.25,0,0.375],
[0.24,0.02309,0.777778,0.5,0.971014,0.95,0.11,0.369755,0,0.212329,0.41859,0.289157,0,0,0.243361,0.333333,0,0.5,0,0.25],
[0.48,0.043198,0.666667,0.5,0.876812,0.733333,0.406875,0.512675,0,0.0590753,0.408921,0.28428,0.529298,0,0.503139,0.333333,0,0.5,0.5,0.375],
[0.371036,0.0313632,0.666667,0.5,0.942029,0.883333,0,0,0,0.359589,0.262009,0.145152,0.42615,0,0.334621,0,0,0.5,0.5,0.375],
[0.322747,0.0136343,0.555556,0.5,0.985507,0.966667,0.1575,0.420455,0,0.078339,0.357143,0.264487,0,0,0.222598,0.333333,0,0.25,0.5,0.125],
[0.3,0.038795,0.333333,0.75,0.565217,0.75,0,0.193182,0,0.267551,0.332813,0.21027,0,0,0.176968,0,0,0.5,0,0.25],
[0.45,0.0562715,0.555556,0.625,0.637681,0.166667,0.0825,0.0284091,0.573394,0.265839,0.4869,0.351979,0,0,0.296234,0.333333,0,0.5,0,0.375],
[0.35,0.0281147,0.444444,0.625,0.623188,0.133333,0,0.273164,0,0.233305,0.364941,0.239816,0,0,0.201835,0,0.5,0.25,0,0.375],
[0.356682,0.0451985,0.555556,0.625,0.768116,0.466667,0,0.220717,0.285059,0,0.2932,0.198508,0,0,0.167069,0.333333,0,0.25,0,0.375],
[0.376053,0.0570006,0.444444,0.625,0.608696,0.1,0.04375,0.273164,0.131717,0.0950342,0.326887,0.399885,0,0,0.336552,0.333333,0,0.5,0,0.375],
[0.23,0.011087,0.444444,0.75,0.362319,0,0,0,0,0.349315,0.254523,0.138267,0,0,0.116369,0,0,0.25,0,0.25],
[0.36,0.0275772,0.555556,0.625,0.753623,0.433333,0.159375,0.275787,0,0.175514,0.324704,0.226908,0,0,0.190971,0.333333,0,0.25,0,0.375],
[0.175,0.0131295,0.888889,0.5,0.92029,0.833333,0.1625,0.498689,0,0.178082,0.485652,0.350832,0,0,0.295268,0.333333,0,0.5,0,0.25],
[0.371036,0.0541775,0.777778,0.5,0.942029,0.866667,0,0.284528,0,0.09375,0.271366,0.156053,0.545278,0,0.403187,0.333333,0,0.5,0.5,0.5],
[0.475,0.0469513,0.444444,0.5,0.550725,0,0.354375,0.0961538,0,0.303082,0.289457,0.170396,0.480387,0,0.382907,0,0,0.5,0,0.5],
[0.4,0.0385473,0.666667,0.625,0.876812,0.716667,0.07,0,0,0.682363,0.497193,0.361446,0,0,0.304201,0,0,0.5,0,0.25],
[0.12,0.00458062,0.555556,0.5,0.92029,0.816667,0.135,0.240385,0,0.0830479,0.232065,0.121343,0.383535,0,0.293337,0.333333,0,0.5,0.5,0.375],
[0.356682,0.0492556,0.777778,0.5,0.934783,0.85,0,0,0,0.750428,0.546787,0.417097,0,0,0.351038,0,0,0.5,0,0.375],
[0.205,0.0169343,0.777778,0.5,0.934783,0.866667,0,0.503934,0,0.188356,0.496881,0.361159,0,0,0.303959,0.333333,0,0.25,0.5,0],
[0.445,0.0452967,0.777778,0.5,0.978261,0.95,0.05,0,0,0.672517,0.490019,0.354848,0,0,0.298648,0,0,0.5,0,0.375]
])       
  
d = [114500,234250,341000,188000,195000,128000,193000,140000,147000,177625,75200,125000,305000,257500,137000,188500,172900,236500,286000,239000]
y_ = pd.Series(data=d)
          

base_EN = ElasticNet()
params = {
    'alpha': [0.1,1,5,10,50,100],
    'l1_ratio': [.1,.2,.25,.5,.75,.8,.9,.95,.99,1]    
    }

grid = GridSearchCV(estimator = base_EN,
                    param_grid = params)

grid.fit(x_,y_)

```


### Expected Results

No error thrown (warnings acceptable).

### Actual Results

```
Traceback (most recent call last):

  File "/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py", line 822, in dispatch_one_batch
    this_batch_duration)

  File "/home/chris/anaconda3/lib/python3.9/queue.py", line 168, in get
    raise Empty

Empty


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/tmp/ipykernel_108025/2697328664.py", line 1, in <module>
    grid.fit(x_,y_)

  File "/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py", line 891, in fit
    return_n_test_samples=True,

  File "/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py", line 1392, in _run_search

  File "/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py", line 838, in evaluate_candidates
    )

  File "/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py", line 1043, in __call__
    Threshold on the size of arrays passed to the workers that

  File "/home/chris/anaconda3/lib/python3.9/site-packages/joblib/parallel.py", line 833, in dispatch_one_batch

  File "/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/model_selection/_search.py", line 839, in <genexpr>
    def fit(self, X, y=None, **params):

  File "/home/chris/anaconda3/lib/python3.9/site-packages/sklearn/utils/fixes.py", line 199, in delayed
    if axis == 0:

NameError: name 'functools' is not defined
```

### Versions

```shell
sklearn.show_versions()
Exception ignored on calling ctypes callback function: <function _ThreadpoolInfo._find_modules_with_dl_iterate_phdr.<locals>.match_module_callback at 0x79e508b1d1f0>
Traceback (most recent call last):
  File "/home/chris/anaconda3/lib/python3.9/site-packages/threadpoolctl.py", line 400, in match_module_callback
    self._make_module_from_path(filepath)
  File "/home/chris/anaconda3/lib/python3.9/site-packages/threadpoolctl.py", line 515, in _make_module_from_path
    module = module_class(filepath, prefix, user_api, internal_api)
  File "/home/chris/anaconda3/lib/python3.9/site-packages/threadpoolctl.py", line 606, in __init__
    self.version = self.get_version()
  File "/home/chris/anaconda3/lib/python3.9/site-packages/threadpoolctl.py", line 646, in get_version
    config = get_config().split()
AttributeError: 'NoneType' object has no attribute 'split'

System:
    python: 3.9.13 (main, Aug 25 2022, 23:26:10)  [GCC 11.2.0]
executable: /home/chris/anaconda3/bin/python
   machine: Linux-6.5.0-26-generic-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.0.2
          pip: 22.2.2
   setuptools: 63.4.1
        numpy: 1.26.2
        scipy: 1.11.3
       Cython: 0.29.32
       pandas: 1.4.4
   matplotlib: 3.5.2
       joblib: 1.3.2
threadpoolctl: 2.2.0

Built with OpenMP: True

threadpoolctl info:
       filepath: /home/chris/anaconda3/lib/libmkl_rt.so.1
         prefix: libmkl_rt
       user_api: blas
   internal_api: mkl
        version: 2021.4-Product
    num_threads: 4
threading_layer: intel

       filepath: /home/chris/anaconda3/lib/libgomp.so.1.0.0
         prefix: libgomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 8

       filepath: /home/chris/anaconda3/lib/python3.9/site-packages/cvxopt.libs/libopenblasp-r0-6ab4772d.3.10.so
         prefix: libopenblas
       user_api: blas
   internal_api: openblas
        version: 0.3.10
    num_threads: 8
threading_layer: pthreads
   architecture: Haswell

       filepath: /home/chris/anaconda3/lib/python3.9/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
         prefix: libgomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 8

       filepath: /home/chris/anaconda3/lib/libiomp5.so
         prefix: libiomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 8
```

COMMENT:
I think that there is something wrong with the scikit-learn versions that you think that you have installed. I tried to reproduce the error with python 3.9 and scikit-learn 1.4.1.post1 and it works. Also I see that the reported version by `sklearn.show_versions()` on your report is 1.0.2. But even with this version, the example does not raise the errror.

So I would be bet that there is something wrong with your install of scikit-learn (there is no call to `functools` inside the `sklearn.utils.fixes` file also.

Labels: Bug