code: def all_modules(modules_to_ignore=None, modules_to_consider=None):
      """Get a list of all modules from nilearn.
  
      This function returns a list of all modules from Nilearn.
  
      .. note::
  
          ``modules_to_ignore`` and ``modules_to_consider``
          cannot be specified simultaneously.
  
      Parameters
      ----------
      modules_to_ignore : :obj:`list` or :obj:`set` of :obj:`str` or None,\
                          default=None
          List of modules to exclude from the listing.
  
          .. note::
  
              This function will ignore ``tests``, ``externals``, and ``data``
              by default.
  
      modules_to_consider : :obj:`list` or :obj:`set` of :obj:`str` or None,\
                            default=None
          List of modules to include in the listing.
  
      Returns
      -------
      all_modules : :obj:`list` of :obj:`str`
          List of modules.
      """
      if (
          modules_to_ignore is not None
          and modules_to_consider is not None
      ):
          raise ValueError(
              "`modules_to_ignore` and `modules_to_consider` "
              "cannot be both specified."
          )
      if modules_to_ignore is None:
          modules_to_ignore = {"data", "tests", "externals", "conftest"}
      all_modules = []
      root = str(Path(__file__).parent.parent)
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          for importer, modname, ispkg in pkgutil.walk_packages(
              path=[root], prefix="nilearn."
          ):
              mod_parts = modname.split(".")
              if modules_to_consider is None:
                  if (
                      all(
                          part not in modules_to_ignore
                          for part in mod_parts
                      )
                      and "._" not in modname
                  ):
                      all_modules.append(modname)
              elif mod_parts[-2] in modules_to_consider:
                  all_modules.append(modname)
      return all_modules
  
file_path: nilearn/nilearn/_utils/__init__.py
imports: import inspect
  import pkgutil
  import warnings
  from importlib import import_module
  from pathlib import Path
  from nilearn._utils.helpers import compare_version, remove_parameters, rename_parameters, stringify_path
  from .cache_mixin import CacheMixin
  from .docs import fill_doc
  from .logger import compose_err_msg
  from .niimg import _repr_niimgs, load_niimg
  from .niimg_conversions import check_niimg, check_niimg_3d, check_niimg_4d
  from .numpy_conversions import as_ndarray
label_desc: Use image node_id 1 for calling a global function with example usage: all_modules(modules_to_ignore, modules_to_consider) and returns: all_modules