We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
push_notebook regression in 0.12.11
The code at https://stackoverflow.com/questions/47583601/update-a-bokeh-span-with-an-interact-element-in-jupyter-notebook works with 0.12.10 but not 0.12.11

Showing anything at all in the notebook seems to generate this error:

<img width="1064" alt="screen shot 2017-12-01 at 10 13 36" src="https://user-images.githubusercontent.com/1078448/33491603-5bdca884-d680-11e7-8cf9-b1aae5904024.png">

The plot will still show, but things like notebook comms do not function. 

cc @mattpap @philippjfr 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bokeh/core/templates.py`
Content:
```
1 ''' Provide Jinja2 templates used by Bokeh to embed Bokeh models
2 (e.g. plots, widgets, layouts) in various ways.
3 
4 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_JS
5 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_NB_JS
6 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_TAG
7 .. bokeh-jinja:: bokeh.core.templates.CSS_RESOURCES
8 .. bokeh-jinja:: bokeh.core.templates.DOC_JS
9 .. bokeh-jinja:: bokeh.core.templates.FILE
10 .. bokeh-jinja:: bokeh.core.templates.JS_RESOURCES
11 .. bokeh-jinja:: bokeh.core.templates.NOTEBOOK_LOAD
12 .. bokeh-jinja:: bokeh.core.templates.PLOT_DIV
13 .. bokeh-jinja:: bokeh.core.templates.SCRIPT_TAG
14 
15 '''
16 from __future__ import absolute_import
17 
18 import json
19 
20 from jinja2 import Environment, PackageLoader, Markup
21 
22 _env = Environment(loader=PackageLoader('bokeh.core', '_templates'))
23 _env.filters['json'] = lambda obj: Markup(json.dumps(obj))
24 
25 JS_RESOURCES = _env.get_template("js_resources.html")
26 
27 CSS_RESOURCES = _env.get_template("css_resources.html")
28 
29 SCRIPT_TAG = _env.get_template("script_tag.html")
30 
31 PLOT_DIV = _env.get_template("plot_div.html")
32 
33 DOC_JS = _env.get_template("doc_js.js")
34 
35 FILE = _env.get_template("file.html")
36 
37 NOTEBOOK_LOAD = _env.get_template("notebook_load.html")
38 
39 AUTOLOAD_JS = _env.get_template("autoload_js.js")
40 
41 AUTOLOAD_NB_JS = _env.get_template("autoload_nb_js.js")
42 
43 AUTOLOAD_TAG = _env.get_template("autoload_tag.html")
44
```

Path: `bokeh/embed/notebook.py`
Content:
```
1 #-----------------------------------------------------------------------------
2 # Copyright (c) 2012 - 2017, Anaconda, Inc. All rights reserved.
3 #
4 # Powered by the Bokeh Development Team.
5 #
6 # The full license is in the file LICENSE.txt, distributed with this software.
7 #-----------------------------------------------------------------------------
8 '''
9 
10 '''
11 
12 #-----------------------------------------------------------------------------
13 # Boilerplate
14 #-----------------------------------------------------------------------------
15 from __future__ import absolute_import, division, print_function, unicode_literals
16 
17 import logging
18 log = logging.getLogger(__name__)
19 
20 from bokeh.util.api import public, internal ; public, internal
21 
22 #-----------------------------------------------------------------------------
23 # Imports
24 #-----------------------------------------------------------------------------
25 
26 # Standard library imports
27 from contextlib import contextmanager
28 
29 # External imports
30 
31 # Bokeh imports
32 from ..core.templates import DOC_JS
33 from ..core.json_encoder import serialize_json
34 from ..settings import settings
35 from ..util.string import encode_utf8
36 from .util import FromCurdoc
37 from .util import check_one_model_or_doc, div_for_render_item, find_existing_docs, standalone_docs_json_and_render_items
38 
39 #-----------------------------------------------------------------------------
40 # Globals and constants
41 #-----------------------------------------------------------------------------
42 
43 #-----------------------------------------------------------------------------
44 # Public API
45 #-----------------------------------------------------------------------------
46 
47 #-----------------------------------------------------------------------------
48 # Internal API
49 #-----------------------------------------------------------------------------
50 
51 @internal((1,0,0))
52 def notebook_content(model, notebook_comms_target=None, theme=FromCurdoc):
53     ''' Return script and div that will display a Bokeh plot in a Jupyter
54     Notebook.
55 
56     The data for the plot is stored directly in the returned HTML.
57 
58     Args:
59         model (Model) : Bokeh object to render
60 
61         notebook_comms_target (str, optional) :
62             A target name for a Jupyter Comms object that can update
63             the document that is rendered to this notebook div
64 
65         theme (Theme, optional) :
66             Defaults to the ``Theme`` instance in the current document.
67             Setting this to ``None`` uses the default theme or the theme
68             already specified in the document. Any other value must be an
69             instance of the ``Theme`` class.
70 
71     Returns:
72         script, div, Document
73 
74     .. note::
75         Assumes :func:`~bokeh.io.notebook.load_notebook` or the equivalent
76         has already been executed.
77 
78     '''
79 
80     model = check_one_model_or_doc(model)
81 
82     # Comms handling relies on the fact that the new_doc returned here
83     # has models with the same IDs as they were started with
84     with _ModelInEmptyDocument(model, apply_theme=theme) as new_doc:
85         (docs_json, render_items) = standalone_docs_json_and_render_items([model])
86 
87     item = render_items[0]
88     if notebook_comms_target:
89         item['notebook_comms_target'] = notebook_comms_target
90     else:
91         notebook_comms_target = ''
92 
93     script = DOC_JS.render(
94         docs_json=serialize_json(docs_json),
95         render_items=serialize_json(render_items)
96     )
97 
98     div = div_for_render_item(item)
99 
100     return encode_utf8(script), encode_utf8(div), new_doc
101 
102 #-----------------------------------------------------------------------------
103 # Private API
104 #-----------------------------------------------------------------------------
105 
106 @contextmanager
107 def _ModelInEmptyDocument(model, apply_theme=None):
108 
109     # Note: Comms handling relies on the fact that the new_doc returned
110     # has models with the same IDs as they were started with
111 
112     from ..document import Document
113     doc = find_existing_docs([model])
114 
115     if apply_theme is FromCurdoc:
116         from ..io import curdoc; curdoc
117         doc.theme = curdoc().theme
118     elif apply_theme is not None:
119         doc.theme = apply_theme
120 
121     model._document = None
122     for ref in model.references():
123         ref._document = None
124     new_doc = Document()
125     new_doc.add_root(model)
126 
127     if settings.perform_document_validation():
128         new_doc.validate()
129 
130     yield new_doc
131 
132     model._document = doc
133     for ref in model.references():
134         ref._document = doc
135 
136 #-----------------------------------------------------------------------------
137 # Code
138 #-----------------------------------------------------------------------------
139
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/bokeh/core/templates.py b/bokeh/core/templates.py
--- a/bokeh/core/templates.py
+++ b/bokeh/core/templates.py
@@ -1,11 +1,12 @@
-''' Provide Jinja2 templates used by Bokeh to embed Bokeh models
-(e.g. plots, widgets, layouts) in various ways.
+''' Provide Jinja2 templates used by Bokeh to embed Bokeh documents and
+models in various ways.
 
 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_JS
 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_NB_JS
 .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_TAG
 .. bokeh-jinja:: bokeh.core.templates.CSS_RESOURCES
 .. bokeh-jinja:: bokeh.core.templates.DOC_JS
+.. bokeh-jinja:: bokeh.core.templates.DOC_NB_JS
 .. bokeh-jinja:: bokeh.core.templates.FILE
 .. bokeh-jinja:: bokeh.core.templates.JS_RESOURCES
 .. bokeh-jinja:: bokeh.core.templates.NOTEBOOK_LOAD
@@ -32,6 +33,8 @@
 
 DOC_JS = _env.get_template("doc_js.js")
 
+DOC_NB_JS = _env.get_template("doc_nb_js.js")
+
 FILE = _env.get_template("file.html")
 
 NOTEBOOK_LOAD = _env.get_template("notebook_load.html")
diff --git a/bokeh/embed/notebook.py b/bokeh/embed/notebook.py
--- a/bokeh/embed/notebook.py
+++ b/bokeh/embed/notebook.py
@@ -29,7 +29,7 @@
 # External imports
 
 # Bokeh imports
-from ..core.templates import DOC_JS
+from ..core.templates import DOC_NB_JS
 from ..core.json_encoder import serialize_json
 from ..settings import settings
 from ..util.string import encode_utf8
@@ -90,7 +90,7 @@
     else:
         notebook_comms_target = ''
 
-    script = DOC_JS.render(
+    script = DOC_NB_JS.render(
         docs_json=serialize_json(docs_json),
         render_items=serialize_json(render_items)
     )

{"golden_diff": "diff --git a/bokeh/core/templates.py b/bokeh/core/templates.py\n--- a/bokeh/core/templates.py\n+++ b/bokeh/core/templates.py\n@@ -1,11 +1,12 @@\n-''' Provide Jinja2 templates used by Bokeh to embed Bokeh models\n-(e.g. plots, widgets, layouts) in various ways.\n+''' Provide Jinja2 templates used by Bokeh to embed Bokeh documents and\n+models in various ways.\n \n .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_JS\n .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_NB_JS\n .. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_TAG\n .. bokeh-jinja:: bokeh.core.templates.CSS_RESOURCES\n .. bokeh-jinja:: bokeh.core.templates.DOC_JS\n+.. bokeh-jinja:: bokeh.core.templates.DOC_NB_JS\n .. bokeh-jinja:: bokeh.core.templates.FILE\n .. bokeh-jinja:: bokeh.core.templates.JS_RESOURCES\n .. bokeh-jinja:: bokeh.core.templates.NOTEBOOK_LOAD\n@@ -32,6 +33,8 @@\n \n DOC_JS = _env.get_template(\"doc_js.js\")\n \n+DOC_NB_JS = _env.get_template(\"doc_nb_js.js\")\n+\n FILE = _env.get_template(\"file.html\")\n \n NOTEBOOK_LOAD = _env.get_template(\"notebook_load.html\")\ndiff --git a/bokeh/embed/notebook.py b/bokeh/embed/notebook.py\n--- a/bokeh/embed/notebook.py\n+++ b/bokeh/embed/notebook.py\n@@ -29,7 +29,7 @@\n # External imports\n \n # Bokeh imports\n-from ..core.templates import DOC_JS\n+from ..core.templates import DOC_NB_JS\n from ..core.json_encoder import serialize_json\n from ..settings import settings\n from ..util.string import encode_utf8\n@@ -90,7 +90,7 @@\n     else:\n         notebook_comms_target = ''\n \n-    script = DOC_JS.render(\n+    script = DOC_NB_JS.render(\n         docs_json=serialize_json(docs_json),\n         render_items=serialize_json(render_items)\n     )\n", "issue": "push_notebook regression in 0.12.11\nThe code at https://stackoverflow.com/questions/47583601/update-a-bokeh-span-with-an-interact-element-in-jupyter-notebook works with 0.12.10 but not 0.12.11\r\n\r\nShowing anything at all in the notebook seems to generate this error:\r\n\r\n<img width=\"1064\" alt=\"screen shot 2017-12-01 at 10 13 36\" src=\"https://user-images.githubusercontent.com/1078448/33491603-5bdca884-d680-11e7-8cf9-b1aae5904024.png\">\r\n\r\nThe plot will still show, but things like notebook comms do not function. \r\n\r\ncc @mattpap @philippjfr \r\n\n", "before_files": [{"content": "''' Provide Jinja2 templates used by Bokeh to embed Bokeh models\n(e.g. plots, widgets, layouts) in various ways.\n\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_JS\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_NB_JS\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_TAG\n.. bokeh-jinja:: bokeh.core.templates.CSS_RESOURCES\n.. bokeh-jinja:: bokeh.core.templates.DOC_JS\n.. bokeh-jinja:: bokeh.core.templates.FILE\n.. bokeh-jinja:: bokeh.core.templates.JS_RESOURCES\n.. bokeh-jinja:: bokeh.core.templates.NOTEBOOK_LOAD\n.. bokeh-jinja:: bokeh.core.templates.PLOT_DIV\n.. bokeh-jinja:: bokeh.core.templates.SCRIPT_TAG\n\n'''\nfrom __future__ import absolute_import\n\nimport json\n\nfrom jinja2 import Environment, PackageLoader, Markup\n\n_env = Environment(loader=PackageLoader('bokeh.core', '_templates'))\n_env.filters['json'] = lambda obj: Markup(json.dumps(obj))\n\nJS_RESOURCES = _env.get_template(\"js_resources.html\")\n\nCSS_RESOURCES = _env.get_template(\"css_resources.html\")\n\nSCRIPT_TAG = _env.get_template(\"script_tag.html\")\n\nPLOT_DIV = _env.get_template(\"plot_div.html\")\n\nDOC_JS = _env.get_template(\"doc_js.js\")\n\nFILE = _env.get_template(\"file.html\")\n\nNOTEBOOK_LOAD = _env.get_template(\"notebook_load.html\")\n\nAUTOLOAD_JS = _env.get_template(\"autoload_js.js\")\n\nAUTOLOAD_NB_JS = _env.get_template(\"autoload_nb_js.js\")\n\nAUTOLOAD_TAG = _env.get_template(\"autoload_tag.html\")\n", "path": "bokeh/core/templates.py"}, {"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2012 - 2017, Anaconda, Inc. All rights reserved.\n#\n# Powered by the Bokeh Development Team.\n#\n# The full license is in the file LICENSE.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n'''\n\n'''\n\n#-----------------------------------------------------------------------------\n# Boilerplate\n#-----------------------------------------------------------------------------\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport logging\nlog = logging.getLogger(__name__)\n\nfrom bokeh.util.api import public, internal ; public, internal\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n# Standard library imports\nfrom contextlib import contextmanager\n\n# External imports\n\n# Bokeh imports\nfrom ..core.templates import DOC_JS\nfrom ..core.json_encoder import serialize_json\nfrom ..settings import settings\nfrom ..util.string import encode_utf8\nfrom .util import FromCurdoc\nfrom .util import check_one_model_or_doc, div_for_render_item, find_existing_docs, standalone_docs_json_and_render_items\n\n#-----------------------------------------------------------------------------\n# Globals and constants\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Public API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Internal API\n#-----------------------------------------------------------------------------\n\n@internal((1,0,0))\ndef notebook_content(model, notebook_comms_target=None, theme=FromCurdoc):\n    ''' Return script and div that will display a Bokeh plot in a Jupyter\n    Notebook.\n\n    The data for the plot is stored directly in the returned HTML.\n\n    Args:\n        model (Model) : Bokeh object to render\n\n        notebook_comms_target (str, optional) :\n            A target name for a Jupyter Comms object that can update\n            the document that is rendered to this notebook div\n\n        theme (Theme, optional) :\n            Defaults to the ``Theme`` instance in the current document.\n            Setting this to ``None`` uses the default theme or the theme\n            already specified in the document. Any other value must be an\n            instance of the ``Theme`` class.\n\n    Returns:\n        script, div, Document\n\n    .. note::\n        Assumes :func:`~bokeh.io.notebook.load_notebook` or the equivalent\n        has already been executed.\n\n    '''\n\n    model = check_one_model_or_doc(model)\n\n    # Comms handling relies on the fact that the new_doc returned here\n    # has models with the same IDs as they were started with\n    with _ModelInEmptyDocument(model, apply_theme=theme) as new_doc:\n        (docs_json, render_items) = standalone_docs_json_and_render_items([model])\n\n    item = render_items[0]\n    if notebook_comms_target:\n        item['notebook_comms_target'] = notebook_comms_target\n    else:\n        notebook_comms_target = ''\n\n    script = DOC_JS.render(\n        docs_json=serialize_json(docs_json),\n        render_items=serialize_json(render_items)\n    )\n\n    div = div_for_render_item(item)\n\n    return encode_utf8(script), encode_utf8(div), new_doc\n\n#-----------------------------------------------------------------------------\n# Private API\n#-----------------------------------------------------------------------------\n\n@contextmanager\ndef _ModelInEmptyDocument(model, apply_theme=None):\n\n    # Note: Comms handling relies on the fact that the new_doc returned\n    # has models with the same IDs as they were started with\n\n    from ..document import Document\n    doc = find_existing_docs([model])\n\n    if apply_theme is FromCurdoc:\n        from ..io import curdoc; curdoc\n        doc.theme = curdoc().theme\n    elif apply_theme is not None:\n        doc.theme = apply_theme\n\n    model._document = None\n    for ref in model.references():\n        ref._document = None\n    new_doc = Document()\n    new_doc.add_root(model)\n\n    if settings.perform_document_validation():\n        new_doc.validate()\n\n    yield new_doc\n\n    model._document = doc\n    for ref in model.references():\n        ref._document = doc\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n", "path": "bokeh/embed/notebook.py"}], "after_files": [{"content": "''' Provide Jinja2 templates used by Bokeh to embed Bokeh documents and\nmodels in various ways.\n\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_JS\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_NB_JS\n.. bokeh-jinja:: bokeh.core.templates.AUTOLOAD_TAG\n.. bokeh-jinja:: bokeh.core.templates.CSS_RESOURCES\n.. bokeh-jinja:: bokeh.core.templates.DOC_JS\n.. bokeh-jinja:: bokeh.core.templates.DOC_NB_JS\n.. bokeh-jinja:: bokeh.core.templates.FILE\n.. bokeh-jinja:: bokeh.core.templates.JS_RESOURCES\n.. bokeh-jinja:: bokeh.core.templates.NOTEBOOK_LOAD\n.. bokeh-jinja:: bokeh.core.templates.PLOT_DIV\n.. bokeh-jinja:: bokeh.core.templates.SCRIPT_TAG\n\n'''\nfrom __future__ import absolute_import\n\nimport json\n\nfrom jinja2 import Environment, PackageLoader, Markup\n\n_env = Environment(loader=PackageLoader('bokeh.core', '_templates'))\n_env.filters['json'] = lambda obj: Markup(json.dumps(obj))\n\nJS_RESOURCES = _env.get_template(\"js_resources.html\")\n\nCSS_RESOURCES = _env.get_template(\"css_resources.html\")\n\nSCRIPT_TAG = _env.get_template(\"script_tag.html\")\n\nPLOT_DIV = _env.get_template(\"plot_div.html\")\n\nDOC_JS = _env.get_template(\"doc_js.js\")\n\nDOC_NB_JS = _env.get_template(\"doc_nb_js.js\")\n\nFILE = _env.get_template(\"file.html\")\n\nNOTEBOOK_LOAD = _env.get_template(\"notebook_load.html\")\n\nAUTOLOAD_JS = _env.get_template(\"autoload_js.js\")\n\nAUTOLOAD_NB_JS = _env.get_template(\"autoload_nb_js.js\")\n\nAUTOLOAD_TAG = _env.get_template(\"autoload_tag.html\")\n", "path": "bokeh/core/templates.py"}, {"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2012 - 2017, Anaconda, Inc. All rights reserved.\n#\n# Powered by the Bokeh Development Team.\n#\n# The full license is in the file LICENSE.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n'''\n\n'''\n\n#-----------------------------------------------------------------------------\n# Boilerplate\n#-----------------------------------------------------------------------------\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport logging\nlog = logging.getLogger(__name__)\n\nfrom bokeh.util.api import public, internal ; public, internal\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\n# Standard library imports\nfrom contextlib import contextmanager\n\n# External imports\n\n# Bokeh imports\nfrom ..core.templates import DOC_NB_JS\nfrom ..core.json_encoder import serialize_json\nfrom ..settings import settings\nfrom ..util.string import encode_utf8\nfrom .util import FromCurdoc\nfrom .util import check_one_model_or_doc, div_for_render_item, find_existing_docs, standalone_docs_json_and_render_items\n\n#-----------------------------------------------------------------------------\n# Globals and constants\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Public API\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Internal API\n#-----------------------------------------------------------------------------\n\n@internal((1,0,0))\ndef notebook_content(model, notebook_comms_target=None, theme=FromCurdoc):\n    ''' Return script and div that will display a Bokeh plot in a Jupyter\n    Notebook.\n\n    The data for the plot is stored directly in the returned HTML.\n\n    Args:\n        model (Model) : Bokeh object to render\n\n        notebook_comms_target (str, optional) :\n            A target name for a Jupyter Comms object that can update\n            the document that is rendered to this notebook div\n\n        theme (Theme, optional) :\n            Defaults to the ``Theme`` instance in the current document.\n            Setting this to ``None`` uses the default theme or the theme\n            already specified in the document. Any other value must be an\n            instance of the ``Theme`` class.\n\n    Returns:\n        script, div, Document\n\n    .. note::\n        Assumes :func:`~bokeh.io.notebook.load_notebook` or the equivalent\n        has already been executed.\n\n    '''\n\n    model = check_one_model_or_doc(model)\n\n    # Comms handling relies on the fact that the new_doc returned here\n    # has models with the same IDs as they were started with\n    with _ModelInEmptyDocument(model, apply_theme=theme) as new_doc:\n        (docs_json, render_items) = standalone_docs_json_and_render_items([model])\n\n    item = render_items[0]\n    if notebook_comms_target:\n        item['notebook_comms_target'] = notebook_comms_target\n    else:\n        notebook_comms_target = ''\n\n    script = DOC_NB_JS.render(\n        docs_json=serialize_json(docs_json),\n        render_items=serialize_json(render_items)\n    )\n\n    div = div_for_render_item(item)\n\n    return encode_utf8(script), encode_utf8(div), new_doc\n\n#-----------------------------------------------------------------------------\n# Private API\n#-----------------------------------------------------------------------------\n\n@contextmanager\ndef _ModelInEmptyDocument(model, apply_theme=None):\n\n    # Note: Comms handling relies on the fact that the new_doc returned\n    # has models with the same IDs as they were started with\n\n    from ..document import Document\n    doc = find_existing_docs([model])\n\n    if apply_theme is FromCurdoc:\n        from ..io import curdoc; curdoc\n        doc.theme = curdoc().theme\n    elif apply_theme is not None:\n        doc.theme = apply_theme\n\n    model._document = None\n    for ref in model.references():\n        ref._document = None\n    new_doc = Document()\n    new_doc.add_root(model)\n\n    if settings.perform_document_validation():\n        new_doc.validate()\n\n    yield new_doc\n\n    model._document = doc\n    for ref in model.references():\n        ref._document = doc\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n", "path": "bokeh/embed/notebook.py"}]}