code: def _get_frontend_environment(
      flow: str, render_fn_or_file: Callable | str, port: int, host: str
  ) -> os._Environ:
      """Returns an _Environ with the environment variables for serving a Frontend app set.
  
      Args:
          flow: The name of the flow, for example root.lit_frontend
          render_fn_or_file: A function to render
          port: The port number, for example 54321
          host: The host, for example 'localhost'
  
      Returns:
          os._Environ: An environment
  
      """
      env = os.environ.copy()
      env["LIGHTNING_FLOW_NAME"] = flow
      env["LIGHTNING_RENDER_PORT"] = str(port)
      env["LIGHTNING_RENDER_ADDRESS"] = str(host)
  
      if isinstance(render_fn_or_file, str):
          env["LIGHTNING_RENDER_FILE"] = render_fn_or_file
      else:
          env["LIGHTNING_RENDER_FUNCTION"] = render_fn_or_file.__name__
          env["LIGHTNING_RENDER_MODULE_FILE"] = inspect.getmodule(
              render_fn_or_file
          ).__file__
  
      return env
  
file_path: pytorch-lightning/src/lightning/app/frontend/utils.py
imports: from __future__ import annotations
  import inspect
  import os
  from typing import Callable
  from lightning.app.core.flow import LightningFlow
  from lightning.app.utilities.state import AppState
label_desc: Use image node_id 3 for calling a global function with example usage: _get_frontend_environment(flow, render_fn_or_file, port, host) and returns: env