Issue 1:
Describe your issue.

Can't run import scipy.stats with numpy nightly

Reproducing Code Example

(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ pip install -U numpy
Collecting numpy
Using cached numpy-1.24.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
Installing collected packages: numpy
Successfully installed numpy-1.24.1
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ python -c 'import scipy.stats'
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ pip uninstall numpy -y
Found existing installation: numpy 1.24.1
Uninstalling numpy-1.24.1:
Successfully uninstalled numpy-1.24.1
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ pip install --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
Looking in indexes: https://pypi.org/simple, https://pypi.anaconda.org/scipy-wheels-nightly/simple
Collecting numpy
Downloading https://pypi.anaconda.org/scipy-wheels-nightly/simple/numpy/1.25.0.dev0%2B405.g720cabc23/numpy-1.25.0.dev0%2B405.g720cabc23-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.3/17.3 MB 9.0 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.25.0.dev0+405.g720cabc23
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ python -c 'import scipy.stats'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/stats/__init__.py", line 484, in <module>
from ._stats_py import *
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/stats/_stats_py.py", line 46, in <module>
from . import distributions
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/stats/distributions.py", line 8, in <module>
from ._distn_infrastructure import (rv_discrete, rv_continuous, rv_frozen)
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/stats/_distn_infrastructure.py", line 25, in <module>
from scipy import integrate
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/integrate/__init__.py", line 91, in <module>
from ._quadrature import *
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/integrate/_quadrature.py", line 35, in <module>
trapezoid = _copy_func(trapezoid)
^^^^^^^^^^^^^^^^^^^^^
File "/home/marcogorelli/pandas-dev/.311venv/lib/python3.11/site-packages/scipy/integrate/_quadrature.py", line 28, in _copy_func
g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__,
^^^^^^^^^^
AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute '__code__'. Did you mean: '__call__'?

SciPy/NumPy/Python version information

1.11.0.dev0+1302.d5d04ef 1.25.0.dev0+405.g720cabc23 sys.version_info(major=3, minor=11, micro=1, releaselevel='final', serial=0)

Issue 2:
See for example this log. Lots of this:

AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute '__code__'

Should be due to numpy/numpy#23020 (Cc @seberg). There are two usages of __code__:

rg __code__
scipy/integrate/_quadrature.py
28: g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__,

scipy/interpolate/_rbf.py
193: hasattr(self.function, '__code__'):
202: argcount = val.__code__.co_argcount

Haven't checked yet what those do exactly, but either way this is a regression that's going to break already-released SciPy versions, so it should be fixed on the NumPy side.