code: def test_all_modules_are_expected():
      """
      Test that we don't add anything that looks like a new public module by
      accident.  Check is based on filenames.
      """
  
      def ignore_errors(name):
          # if versions of other array libraries are installed which are incompatible
          # with the installed NumPy version, there can be errors on importing
          # `array_api_compat`. This should only raise if SciPy is configured with
          # that library as an available backend.
          for backend, dir_name in {
              "cupy": "cupy",
              "pytorch": "torch",
          }.items():
              path = f"array_api_compat.{dir_name}"
              if path in name and backend not in xp_available_backends:
                  return
          raise
  
      modnames = []
  
      for _, modname, _ in pkgutil.walk_packages(
          path=scipy.__path__,
          prefix=scipy.__name__ + ".",
          onerror=ignore_errors,
      ):
          if is_unexpected(modname) and modname not in SKIP_LIST:
              # We have a name that is new.  If that's on purpose, add it to
              # PUBLIC_MODULES.  We don't expect to have to add anything to
              # PRIVATE_BUT_PRESENT_MODULES.  Use an underscore in the name!
              modnames.append(modname)
  
      if modnames:
          raise AssertionError(f"Found unexpected modules: {modnames}")
  
file_path: scipy/scipy/_lib/tests/test_public_api.py
imports: import pkgutil
  import types
  import importlib
  import warnings
  from importlib import import_module
  import pytest
  import scipy
  from scipy.conftest import xp_available_backends
label_desc: Use image node_id 3 for calling a global function with example usage: test_all_modules_are_expected() without return types