code: def import_module(module_or_filename):
      """Imports a given module or filename.
  
      If the module_or_filename exists in the file system and ends with .py, we
      attempt to import it. If that import fails, try to import it as a module.
  
      Args:
        module_or_filename (str): string name of path or module.
  
      Raises:
        ValueError: if the given file is invalid.
        IOError: if the file or module can not be found or imported.
  
      Returns:
        Tuple[ModuleType, str]: returns the imported module and the module name,
          usually extracted from the path itself.
      """
  
      if os.path.exists(module_or_filename):
          # importlib.util.spec_from_file_location requires .py
          if not module_or_filename.endswith(".py"):
              try:  # try as module instead
                  return import_from_module_name(module_or_filename)
              except ImportError:
                  raise ValueError(
                      "Fire can only be called on .py files."
                  )
  
          return import_from_file_path(module_or_filename)
  
      if (
          os.path.sep in module_or_filename
      ):  # Use / to detect if it was a filename.
          raise IOError(
              "Fire was passed a filename which could not be found."
          )
  
      return import_from_module_name(module_or_filename)
  
file_path: python-fire/fire/__main__.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import importlib
  import os
  import sys
  import fire
label_desc: Use image node_id 3 for calling a global function with example usage: import_module(module_or_filename) and returns: import_from_module_name, import_from_file_path, import_from_module_name