code: def _load_objects_from_file(
      filepath: str,
      target_type: Type,
      raise_exception: bool = False,
      mock_imports: bool = False,
      env_vars: Dict[str, str] = {},
  ) -> Tuple[List[Any], types.ModuleType]:
      """Load all of the top-level objects of the given type from a file.
  
      Args:
          filepath: The file to load from.
          target_type: The type of object to load.
          raise_exception: If ``True`` exceptions will be raised, otherwise exceptions will trigger system exit.
          mock_imports: If ``True`` imports of missing packages will be replaced with a mock. This can allow the object to
              be loaded without installing dependencies.
  
      """
  
      # Taken from StreamLit: https://github.com/streamlit/streamlit/blob/develop/lib/streamlit/script_runner.py#L313
  
      # In order for imports to work in a non-package, Python normally adds the current working directory to the
      # system path, not however when running from an entry point like the `lightning` CLI command. So we do it manually:
      with _patch_sys_path(os.path.dirname(os.path.abspath(filepath))):
          code = _create_code(filepath)
          with _create_fake_main_module(filepath) as module:
              try:
                  with _add_to_env(env_vars), _patch_sys_argv():
                      if mock_imports:
                          with _mock_missing_imports():
                              exec(code, module.__dict__)  # noqa: S102
                      else:
                          exec(code, module.__dict__)  # noqa: S102
              except Exception as ex:
                  if raise_exception:
                      raise ex
                  _prettifiy_exception(filepath)
  
      return [
          v
          for v in module.__dict__.values()
          if isinstance(v, target_type)
      ], module
  
imports: import inspect
  import os
  import sys
  import traceback
  import types
  from contextlib import contextmanager
  from copy import copy
  from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Type, Union
  from lightning.app.utilities.exceptions import MisconfigurationException
  from lightning.app.utilities.app_helpers import Logger, _mock_missing_imports
label_desc: Use image node_id 2 for calling a global function with example usage: _load_objects_from_file(filepath, target_type, raise_exception, mock_imports, env_vars) and returns: unknown,  module