code: def _new_doc() -> Document:
      # TODO: embed APIs need to actually respect the existing document's
      # configuration, but for now this is better than nothing.
      from ..io import curdoc
  
      doc = Document()
      callbacks = curdoc().callbacks._js_event_callbacks
      doc.callbacks._js_event_callbacks.update(callbacks)
      return doc
  
imports: from __future__ import annotations
  import logging
  import re
  from contextlib import contextmanager
  from typing import TYPE_CHECKING, Any, Iterator, Sequence
  from weakref import WeakKeyDictionary
  from ..core.types import ID
  from ..document.document import Document
  from ..model import Model, collect_models
  from ..settings import settings
  from ..themes.theme import Theme
  from ..util.dataclasses import dataclass, field
  from ..util.serialization import make_globally_unique_css_safe_id, make_globally_unique_id
label_desc: Use image node_id 7 for calling a global function with example usage: _new_doc() and returns: doc