code: def curdoc() -> Document:
      """Return the document for the current default state.
  
      Returns:
          Document : the current default document object.
  
      """
      if len(_PATCHED_CURDOCS) > 0:
          doc = _PATCHED_CURDOCS[-1]()
          if doc is None:
              raise RuntimeError(
                  "Patched curdoc has been previously destroyed"
              )
          return cast(
              Document, doc
          )  # UnlockedDocumentProxy -> Document
      return curstate().document
  
file_path: bokeh/src/bokeh/io/doc.py
imports: from __future__ import annotations
  import logging
  import weakref
  from contextlib import contextmanager
  from typing import TYPE_CHECKING, Iterator, cast
  from ..document import Document
  from .state import curstate
label_desc: Use image node_id 1 for calling a global function with example usage: curdoc() and returns: curstate, cast