code: def safe_import(module, *, msg=None, alt=None):
      """A function used to import modules that may not be available
  
      This function will attempt to import a module with the given name, but it
      will not throw an ImportError if the module is not found. Instead, it will
      return a placeholder object which will raise an exception only if used.
  
      Parameters
      ----------
      module: str
          The name of the module to import.
      msg: str or None
          An optional error message to be displayed if this module is used
          after a failed import.
      alt: object
          An optional module to be used in place of the given module if it
          fails to import
  
      Returns
      -------
      object
          The imported module, the given alternate, or a class derived from
          UnavailableMeta.
      """
      try:
          return importlib.import_module(module)
      except ImportError:
          exception_text = traceback.format_exc()
          logger.debug(
              f"Import of {module} failed with: {exception_text}"
          )
      except Exception:
          exception_text = traceback.format_exc()
          logger.info(
              f"Import of {module} failed with: {exception_text}"
          )
      if msg is None:
          msg = f"{module} could not be imported"
      if alt is None:
          return UnavailableMeta(
              module.rsplit(".")[-1], (), {"_msg": msg}
          )
      else:
          return alt
  
imports: import importlib
  import traceback
  from contextlib import contextmanager
  from cuml.internals.device_support import CPU_ENABLED, GPU_ENABLED
  from cuml.internals import logger
label_desc: Use image node_id 4 for calling a global function with example usage: safe_import(module) and returns: importlib, UnavailableMeta, alt