code: def _collect_work_layout(
      work: "lightning.app.LightningWork",
  ) -> Union[None, str, Frontend, _MagicMockJsonSerializable]:
      """Check if ``configure_layout`` is overridden on the given work and return the work layout (either a string, a
      ``Frontend`` object, or an instance of a mocked import).
  
      Args:
          work: The work to collect the layout for.
  
      Raises:
          TypeError: If the value returned by ``configure_layout`` is not of a supported format.
  
      """
      work_layout = (
          work.configure_layout()
          if is_overridden("configure_layout", work)
          else work.url
      )
  
      if work_layout is None:
          return None
      if isinstance(work_layout, str):
          url = work_layout
          # The URL isn't fully defined yet. Looks something like ``self.work.url + /something``.
          if url and not url.startswith("/"):
              return url
          return ""
      if isinstance(
          work_layout, (Frontend, _MagicMockJsonSerializable)
      ):
          return work_layout
      raise TypeError(
          f"""
      The value returned by `{work.__class__.__name__}.configure_layout()` is of an unsupported type.
  
      {repr(work_layout)}
  
      Return a `Frontend` or a URL string, for example:
  
      class {work.__class__.__name__}(LightningWork):
          def configure_layout(self):
              return MyFrontend() OR 'http://some/url'
      """
      )
  
file_path: pytorch-lightning/src/lightning/app/utilities/layout.py
imports: import inspect
  import warnings
  from typing import Dict, List, Union
  import lightning.app
  from lightning.app.frontend.frontend import Frontend
  from lightning.app.utilities.app_helpers import _MagicMockJsonSerializable, is_overridden
  from lightning.app.utilities.cloud import is_running_in_cloud
label_desc: Use image node_id 4 for calling a global function with example usage: _collect_work_layout(work) and returns: None, str, work_layout, url