code: def load_app_from_file(
      filepath: str,
      raise_exception: bool = False,
      mock_imports: bool = False,
      env_vars: Dict[str, str] = {},
  ) -> "LightningApp":
      """Load a LightningApp from a file.
  
      Arguments:
          filepath:  The path to the file containing the LightningApp.
          raise_exception: If True, raise an exception if the app cannot be loaded.
  
      """
      from lightning.app.core.app import LightningApp
  
      apps, main_module = _load_objects_from_file(
          filepath,
          LightningApp,
          raise_exception=raise_exception,
          mock_imports=mock_imports,
          env_vars=env_vars,
      )
  
      # TODO: Remove this, downstream code shouldn't depend on side-effects here but it does
      sys.path.append(os.path.dirname(os.path.abspath(filepath)))
      sys.modules["__main__"] = main_module
  
      if len(apps) > 1:
          raise MisconfigurationException(
              f"There should not be multiple apps instantiated within a file. Found {apps}"
          )
      if len(apps) == 1:
          return apps[0]
  
      raise MisconfigurationException(
          f"The provided file {filepath} does not contain a LightningApp. Instantiate your app at the module level"
          " like so: `app = LightningApp(flow, ...)`"
      )
  
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 4 for calling a global function with example usage: load_app_from_file(filepath, raise_exception, mock_imports, env_vars) and returns: apps