code: def _soft_import(name, purpose, strict=True):
      """Import soft dependencies, providing informative errors on failure.
  
      Parameters
      ----------
      name : str
          Name of the module to be imported. For example, 'pandas'.
      purpose : str
          A very brief statement (formulated as a noun phrase) explaining what
          functionality the package provides to MNE-Python.
      strict : bool
          Whether to raise an error if module import fails.
      """
  
      # so that error msg lines are aligned
      def indent(x):
          return x.rjust(len(x) + 14)
  
      # Mapping import namespaces to their pypi package name
      pip_name = dict(
          sklearn="scikit-learn",
          mne_bids="mne-bids",
          mne_nirs="mne-nirs",
          mne_features="mne-features",
          mne_qt_browser="mne-qt-browser",
          mne_connectivity="mne-connectivity",
          mne_gui_addons="mne-gui-addons",
          pyvista="pyvistaqt",
      ).get(name, name)
  
      try:
          mod = import_module(name)
          return mod
      except (ImportError, ModuleNotFoundError):
          if strict:
              raise RuntimeError(
                  f"For {purpose} to work, the {name} module is needed, "
                  + "but it could not be imported.\n"
                  + "\n".join(
                      (
                          indent(
                              "use the following installation method "
                              "appropriate for your environment:"
                          ),
                          indent(f"'pip install {pip_name}'"),
                          indent(
                              f"'conda install -c conda-forge {pip_name}'"
                          ),
                      )
                  )
              )
          else:
              return False
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 16 for calling a global function with example usage: _soft_import(name, purpose, strict) and returns: x, mod, False