Scipy Warning Issued Only After LinearRegression calls

### Describe the bug

I am working on a project for work and the data is sensitive and I share those files.  I've reduced the issue to the attached code and longer description.

I get scipy MatReadWarnings when I called sklearn linear regression module.  Further, the mat read warning I get is a deprecated method.  This warning shows up if and only if I call the linear regression function that uses the sklearn.linear_model.LinearRegression class, just importing it did not cause any issues.  No warning messages appeared.

My environment is using scipy 1.10.1 and scikit-learn 1.2.2.

Any thoughts?

### Steps/Code to Reproduce

I am working on a project for work and the data is sensitive and I share those files.  I've reduced the issue to the following code.

```python
import scipy.io as sio
from sklearn.linear_model import LinearRegression as LR
import time

def linreg(x,y):
    model = LR().fit(x,y)
    r = model.score(x,y)
    fitx = [min(x),max(x)]
    fity = model.predict(fitx)
    
    return r, fitx, fity


if __name__ == '__main__':
    
    
    fname = 'file{}.mat'
    for i in range(5):
        print("Loop {}".format(i))
        mat = sio.matlab.loadmat(fname.format(i))
        
        print("Mat Loaded")
        
        x = mat['Var0']
        y = mat['Var1']
 
        r, fx, fy = linreg(x,y)
        print("sklearn Called")
        time.sleep(1)
```

If I run this code- I get this output 

> Loop 0
> Mat Loaded
> sklearn Called
> C:\...\anaconda3\envs\HCAcal\lib\site-packages\scipy\io\matlab\_mio.py:227: MatReadWarning: Duplicate variable name "None" in stream - replacing previous with new
> Consider mio5.varmats_from_mat to split file into single variable files
>   matfile_dict = MR.get_variables(variable_names)

If I comment out the line `r, fx, fy = linreg(x,y)` no error message appears.
If I comment out the line time.sleep(1) then there is a bit more randomness to the output. In the sense it will do it in groups of 3-5:

> Loop 0
> Mat Loaded
> sklearn Called
> Loop 1
> Mat Loaded
> sklearn Called
> C:\...\anaconda3\envs\HCAcal\lib\site-packages\scipy\io\matlab\_mio.py:227: MatReadWarning: Duplicate variable name "None" in stream - replacing previous with new
> Consider mio5.varmats_from_mat to split file into single variable files
>   matfile_dict = MR.get_variables(variable_names)
> C:\...\anaconda3\envs\HCAcal\lib\site-packages\scipy\io\matlab\_mio.py:227: MatReadWarning: Duplicate variable name "None" in stream - replacing previous with new
> Consider mio5.varmats_from_mat to split file into single variable files
>   matfile_dict = MR.get_variables(variable_names)

Finally, a really bizzare issue is that if I comment out the `linreg` call after having it on, the first time I run the script with it commented out throws the same warning, but then it disappears for the rest of them.  And I run it back to back commented out, no warning.  So that goes-
LinReg Call - All get Warnings
LinReg Commented Out First Time - First one gets warning
LinReg commented Out after first - No Warning

I have tried to create a test set of mat files to share but I have not been able to do so.  One would think it is related to my Mats, but I have triple checked that there is no variable 'None' in any of them, let alone duplicates.  Which also seems like part of a garbage collection step, but I'm just making noise on that.  No idea.  The biggest thing is that this error does not happen when I load the mat and do not call LinearRegression module from scikit-learn.  

It would seem there is some memory freeing issue but I cannot really figure out anything interesting using the garbage tools in python.  I tried to create large mat files to simulate the ones I cannot share, but so far, the problem is a unique to the mat files as well.  Which doesn't help matters, but the issue still stands that I get a deprecated warning from scikit learn for scipy.

Finally, the message output is actually deprecated in scipy 1.10.1
https://github.com/scipy/scipy/blob/main/scipy/io/matlab/mio5.py

My environment is using scipy 1.10.1 and scikit-learn 1.2.2.


Any thoughts?

### Expected Results

> Loop 0
> Mat Loaded
> sklearn Called
> Loop 1
> Mat Loaded
> sklearn Called

### Actual Results

> Loop 0
> Mat Loaded
> sklearn Called
> C:\...\anaconda3\envs\HCAcal\lib\site-packages\scipy\io\matlab\_mio.py:227: MatReadWarning: Duplicate variable name "None" in stream - replacing previous with new
> Consider mio5.varmats_from_mat to split file into single variable files
>   matfile_dict = MR.get_variables(variable_names)
> Loop 1
> Mat Loaded
> sklearn Called
> C:\...\anaconda3\envs\HCAcal\lib\site-packages\scipy\io\matlab\_mio.py:227: MatReadWarning: Duplicate variable name "None" in stream - replacing previous with new
> Consider mio5.varmats_from_mat to split file into single variable files
>   matfile_dict = MR.get_variables(variable_names)

### Versions

```shell
System:
    python: 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\i12500198\AppData\Local\anaconda3\envs\HCAcal\python.exe
   machine: Windows-10-10.0.19045-SP0

Python dependencies:
      sklearn: 1.2.2
          pip: 23.1.2
   setuptools: 67.8.0
        numpy: 1.24.3
        scipy: 1.10.1
       Cython: None
       pandas: 1.5.3
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 2.2.0

Built with OpenMP: True

threadpoolctl info:
       filepath: C:\Users\i12500198\AppData\Local\anaconda3\envs\HCAcal\Library\bin\mkl_rt.1.dll
         prefix: mkl_rt
       user_api: blas
   internal_api: mkl
        version: 2021.4-Product
    num_threads: 8
threading_layer: intel

       filepath: C:\Users\i12500198\AppData\Local\anaconda3\envs\HCAcal\vcomp140.dll
         prefix: vcomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 16

       filepath: C:\Users\i12500198\AppData\Local\anaconda3\envs\HCAcal\Library\bin\libiomp5md.dll
         prefix: libiomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 16
```

COMMENT:
Thanks for all the investigation. It sounds like this is related to the file, their contents, how they were created and then loaded. Maybe the best place (if you find out more/have files to share) is the scipy issue tracker. I think you will have a higher chance of meeting someone who understands the intricacies of the file I/O there.

Labels: Bug, Needs Investigation