code: def _title_from_models(
      models: Sequence[Model | Document], title: str | None
  ) -> str:
      # use override title
      if title is not None:
          return title
  
      # use title from any listed document
      for p in models:
          if isinstance(p, Document):
              return p.title
  
      # use title from any model's document
      for p in cast(Sequence[Model], models):
          if p.document is not None:
              return p.document.title
  
      # use default title
      return DEFAULT_TITLE
  
imports: from __future__ import annotations
  import logging
  from typing import TYPE_CHECKING, Any, Literal, Sequence, TypedDict, Union, cast, overload
  from ..None import __version__
  from ..core.templates import AUTOLOAD_JS, AUTOLOAD_TAG, FILE, MACROS, ROOT_DIV
  from ..document.document import DEFAULT_TITLE, Document
  from ..model import Model
  from ..resources import Resources, ResourcesLike
  from ..themes import Theme
  from .bundle import Script, bundle_for_objs_and_resources
  from .elements import html_page_for_render_items, script_for_render_items
  from .util import FromCurdoc, OutputDocumentFor, RenderRoot, standalone_docs_json, standalone_docs_json_and_render_items
  from .wrappers import wrap_in_onload
label_desc: Use image node_id 12 for calling a global function with example usage: _title_from_models(models, title) and returns: DEFAULT_TITLE, title, p, p