We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pn.template attribute not found when lazy loading panel
panel==1.3.8

As Panel takes ~2secs to import I would like to lazy load it in one of my packages. This package provides different utility functions. Only some are panel related.

Lazy loading of modules in Python is defined here https://docs.python.org/3/library/importlib.html#implementing-lazy-imports. When I use that I get an `AttributeError` because the attribute `template` is not defined on `panel`. Without lazy loading this works.

## Minimum reproducible example

`lazy_loader.py`

```python
import importlib.util
import sys

def lazy_import(name):
    spec = importlib.util.find_spec(name)
    loader = importlib.util.LazyLoader(spec.loader)
    spec.loader = loader
    module = importlib.util.module_from_spec(spec)
    sys.modules[name] = module
    loader.exec_module(module)
    return module

pn = lazy_import("panel")
# import panel as pn

def extension():
    return pn.extension()
```

`app.py`

```python
from lazy_loader import extension
import panel as pn

extension()

pn.template.FastListTemplate(title="Hello", main=["world"]).servable()
```

```bash
panel serve app.py --autoreload --index app
```

![image](https://github.com/holoviz/panel/assets/42288570/38eb6479-88ba-4e4e-a256-f817b9226ba5)
¨

```bash
AttributeError: module 'panel' has no attribute 'template'

Traceback (most recent call last):
  File "/home/jovyan/repos/aw-lib/.venv/lib/python3.11/site-packages/bokeh/application/handlers/code_runner.py", line 229, in run
    exec(self._code, module.__dict__)
  File "/home/jovyan/repos/aw-lib/app.py", line 6, in <module>
    pn.template.FastListTemplate(title="Hello", main=["world"]).servable()
    ^^^^^^^^^^^
AttributeError: module 'panel' has no attribute 'template'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `panel/__init__.py`
Content:
```
1 """
2 Panel is a high level app and dashboarding framework
3 ====================================================
4 
5 Panel is an open-source Python library that lets you create custom
6 interactive web apps and dashboards by connecting user-defined widgets
7 to plots, images, tables, or text.
8 
9 Panel works with the tools you know and ❤️.
10 
11 Check out https://panel.holoviz.org/
12 
13 .. figure:: https://user-images.githubusercontent.com/42288570/152672367-6c239073-0ea0-4a2b-a4c0-817e8090e877.gif
14    :alt: Panel Dashboard
15 
16    Panel Dashboard
17 
18 How to develop a Panel app in 3 simple steps
19 --------------------------------------------
20 
21 - Write the app
22 
23 >>> import panel as pn
24 >>> pn.extension(sizing_mode="stretch_width", template="fast")
25 >>> pn.state.template.param.update(title="My Data App")
26 >>> pn.panel(some_python_object).servable()
27 
28 - Run your app
29 
30 $ panel serve my_script.py --autoreload --show
31 
32 or
33 
34 $ panel serve my_notebook.ipynb --autoreload --show
35 
36 The app will be available in your browser!
37 
38 - Change your code and save it
39 
40 The app will reload with your changes!
41 
42 You can also add automatic reload to jupyterlab. Check out
43 https://blog.holoviz.org/panel_0.12.0.html#JupyterLab-previews
44 
45 To learn more about Panel check out
46 https://panel.holoviz.org/getting_started/index.html
47 """
48 from param import rx
49 
50 from . import chat  # noqa
51 from . import layout  # noqa
52 from . import links  # noqa
53 from . import pane  # noqa
54 from . import param  # noqa
55 from . import pipeline  # noqa
56 from . import reactive  # noqa
57 from . import viewable  # noqa
58 from . import widgets  # noqa
59 from .config import __version__, config, panel_extension as extension  # noqa
60 from .depends import bind, depends  # noqa
61 from .interact import interact  # noqa
62 from .io import (  # noqa
63     _jupyter_server_extension_paths, cache, ipywidget, serve, state,
64 )
65 from .layout import (  # noqa
66     Accordion, Card, Column, FlexBox, FloatPanel, GridBox, GridSpec, GridStack,
67     HSpacer, Row, Spacer, Swipe, Tabs, VSpacer, WidgetBox,
68 )
69 from .pane import panel  # noqa
70 from .param import Param, ReactiveExpr  # noqa
71 from .template import Template  # noqa
72 from .widgets import indicators, widget  # noqa
73 
74 __all__ = (
75     "__version__",
76     "Accordion",
77     "Card",
78     "chat",
79     "Column",
80     "FlexBox",
81     "FloatPanel",
82     "GridBox",
83     "GridSpec",
84     "GridStack",
85     "HSpacer",
86     "Param",
87     "ReactiveExpr",
88     "Row",
89     "Spacer",
90     "Tabs",
91     "Template",
92     "VSpacer",
93     "WidgetBox",
94     "bind",
95     "cache",
96     "config",
97     "depends",
98     "extension",
99     "indicators",
100     "interact",
101     "ipywidget",
102     "layout",
103     "links",
104     "pane",
105     "panel",
106     "param",
107     "pipeline",
108     "rx",
109     "serve",
110     "state",
111     "viewable",
112     "widgets",
113     "widget"
114 )
115
```
--- 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/panel/__init__.py b/panel/__init__.py
--- a/panel/__init__.py
+++ b/panel/__init__.py
@@ -54,6 +54,7 @@
 from . import param  # noqa
 from . import pipeline  # noqa
 from . import reactive  # noqa
+from . import template  # noqa
 from . import viewable  # noqa
 from . import widgets  # noqa
 from .config import __version__, config, panel_extension as extension  # noqa
@@ -108,6 +109,7 @@
     "rx",
     "serve",
     "state",
+    "template",
     "viewable",
     "widgets",
     "widget"

{"golden_diff": "diff --git a/panel/__init__.py b/panel/__init__.py\n--- a/panel/__init__.py\n+++ b/panel/__init__.py\n@@ -54,6 +54,7 @@\n from . import param  # noqa\n from . import pipeline  # noqa\n from . import reactive  # noqa\n+from . import template  # noqa\n from . import viewable  # noqa\n from . import widgets  # noqa\n from .config import __version__, config, panel_extension as extension  # noqa\n@@ -108,6 +109,7 @@\n     \"rx\",\n     \"serve\",\n     \"state\",\n+    \"template\",\n     \"viewable\",\n     \"widgets\",\n     \"widget\"\n", "issue": "pn.template attribute not found when lazy loading panel\npanel==1.3.8\r\n\r\nAs Panel takes ~2secs to import I would like to lazy load it in one of my packages. This package provides different utility functions. Only some are panel related.\r\n\r\nLazy loading of modules in Python is defined here https://docs.python.org/3/library/importlib.html#implementing-lazy-imports. When I use that I get an `AttributeError` because the attribute `template` is not defined on `panel`. Without lazy loading this works.\r\n\r\n## Minimum reproducible example\r\n\r\n`lazy_loader.py`\r\n\r\n```python\r\nimport importlib.util\r\nimport sys\r\n\r\ndef lazy_import(name):\r\n    spec = importlib.util.find_spec(name)\r\n    loader = importlib.util.LazyLoader(spec.loader)\r\n    spec.loader = loader\r\n    module = importlib.util.module_from_spec(spec)\r\n    sys.modules[name] = module\r\n    loader.exec_module(module)\r\n    return module\r\n\r\npn = lazy_import(\"panel\")\r\n# import panel as pn\r\n\r\ndef extension():\r\n    return pn.extension()\r\n```\r\n\r\n`app.py`\r\n\r\n```python\r\nfrom lazy_loader import extension\r\nimport panel as pn\r\n\r\nextension()\r\n\r\npn.template.FastListTemplate(title=\"Hello\", main=[\"world\"]).servable()\r\n```\r\n\r\n```bash\r\npanel serve app.py --autoreload --index app\r\n```\r\n\r\n![image](https://github.com/holoviz/panel/assets/42288570/38eb6479-88ba-4e4e-a256-f817b9226ba5)\r\n\u00a8\r\n\r\n```bash\r\nAttributeError: module 'panel' has no attribute 'template'\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/jovyan/repos/aw-lib/.venv/lib/python3.11/site-packages/bokeh/application/handlers/code_runner.py\", line 229, in run\r\n    exec(self._code, module.__dict__)\r\n  File \"/home/jovyan/repos/aw-lib/app.py\", line 6, in <module>\r\n    pn.template.FastListTemplate(title=\"Hello\", main=[\"world\"]).servable()\r\n    ^^^^^^^^^^^\r\nAttributeError: module 'panel' has no attribute 'template'\r\n```\n", "before_files": [{"content": "\"\"\"\nPanel is a high level app and dashboarding framework\n====================================================\n\nPanel is an open-source Python library that lets you create custom\ninteractive web apps and dashboards by connecting user-defined widgets\nto plots, images, tables, or text.\n\nPanel works with the tools you know and \u2764\ufe0f.\n\nCheck out https://panel.holoviz.org/\n\n.. figure:: https://user-images.githubusercontent.com/42288570/152672367-6c239073-0ea0-4a2b-a4c0-817e8090e877.gif\n   :alt: Panel Dashboard\n\n   Panel Dashboard\n\nHow to develop a Panel app in 3 simple steps\n--------------------------------------------\n\n- Write the app\n\n>>> import panel as pn\n>>> pn.extension(sizing_mode=\"stretch_width\", template=\"fast\")\n>>> pn.state.template.param.update(title=\"My Data App\")\n>>> pn.panel(some_python_object).servable()\n\n- Run your app\n\n$ panel serve my_script.py --autoreload --show\n\nor\n\n$ panel serve my_notebook.ipynb --autoreload --show\n\nThe app will be available in your browser!\n\n- Change your code and save it\n\nThe app will reload with your changes!\n\nYou can also add automatic reload to jupyterlab. Check out\nhttps://blog.holoviz.org/panel_0.12.0.html#JupyterLab-previews\n\nTo learn more about Panel check out\nhttps://panel.holoviz.org/getting_started/index.html\n\"\"\"\nfrom param import rx\n\nfrom . import chat  # noqa\nfrom . import layout  # noqa\nfrom . import links  # noqa\nfrom . import pane  # noqa\nfrom . import param  # noqa\nfrom . import pipeline  # noqa\nfrom . import reactive  # noqa\nfrom . import viewable  # noqa\nfrom . import widgets  # noqa\nfrom .config import __version__, config, panel_extension as extension  # noqa\nfrom .depends import bind, depends  # noqa\nfrom .interact import interact  # noqa\nfrom .io import (  # noqa\n    _jupyter_server_extension_paths, cache, ipywidget, serve, state,\n)\nfrom .layout import (  # noqa\n    Accordion, Card, Column, FlexBox, FloatPanel, GridBox, GridSpec, GridStack,\n    HSpacer, Row, Spacer, Swipe, Tabs, VSpacer, WidgetBox,\n)\nfrom .pane import panel  # noqa\nfrom .param import Param, ReactiveExpr  # noqa\nfrom .template import Template  # noqa\nfrom .widgets import indicators, widget  # noqa\n\n__all__ = (\n    \"__version__\",\n    \"Accordion\",\n    \"Card\",\n    \"chat\",\n    \"Column\",\n    \"FlexBox\",\n    \"FloatPanel\",\n    \"GridBox\",\n    \"GridSpec\",\n    \"GridStack\",\n    \"HSpacer\",\n    \"Param\",\n    \"ReactiveExpr\",\n    \"Row\",\n    \"Spacer\",\n    \"Tabs\",\n    \"Template\",\n    \"VSpacer\",\n    \"WidgetBox\",\n    \"bind\",\n    \"cache\",\n    \"config\",\n    \"depends\",\n    \"extension\",\n    \"indicators\",\n    \"interact\",\n    \"ipywidget\",\n    \"layout\",\n    \"links\",\n    \"pane\",\n    \"panel\",\n    \"param\",\n    \"pipeline\",\n    \"rx\",\n    \"serve\",\n    \"state\",\n    \"viewable\",\n    \"widgets\",\n    \"widget\"\n)\n", "path": "panel/__init__.py"}], "after_files": [{"content": "\"\"\"\nPanel is a high level app and dashboarding framework\n====================================================\n\nPanel is an open-source Python library that lets you create custom\ninteractive web apps and dashboards by connecting user-defined widgets\nto plots, images, tables, or text.\n\nPanel works with the tools you know and \u2764\ufe0f.\n\nCheck out https://panel.holoviz.org/\n\n.. figure:: https://user-images.githubusercontent.com/42288570/152672367-6c239073-0ea0-4a2b-a4c0-817e8090e877.gif\n   :alt: Panel Dashboard\n\n   Panel Dashboard\n\nHow to develop a Panel app in 3 simple steps\n--------------------------------------------\n\n- Write the app\n\n>>> import panel as pn\n>>> pn.extension(sizing_mode=\"stretch_width\", template=\"fast\")\n>>> pn.state.template.param.update(title=\"My Data App\")\n>>> pn.panel(some_python_object).servable()\n\n- Run your app\n\n$ panel serve my_script.py --autoreload --show\n\nor\n\n$ panel serve my_notebook.ipynb --autoreload --show\n\nThe app will be available in your browser!\n\n- Change your code and save it\n\nThe app will reload with your changes!\n\nYou can also add automatic reload to jupyterlab. Check out\nhttps://blog.holoviz.org/panel_0.12.0.html#JupyterLab-previews\n\nTo learn more about Panel check out\nhttps://panel.holoviz.org/getting_started/index.html\n\"\"\"\nfrom param import rx\n\nfrom . import chat  # noqa\nfrom . import layout  # noqa\nfrom . import links  # noqa\nfrom . import pane  # noqa\nfrom . import param  # noqa\nfrom . import pipeline  # noqa\nfrom . import reactive  # noqa\nfrom . import template  # noqa\nfrom . import viewable  # noqa\nfrom . import widgets  # noqa\nfrom .config import __version__, config, panel_extension as extension  # noqa\nfrom .depends import bind, depends  # noqa\nfrom .interact import interact  # noqa\nfrom .io import (  # noqa\n    _jupyter_server_extension_paths, cache, ipywidget, serve, state,\n)\nfrom .layout import (  # noqa\n    Accordion, Card, Column, FlexBox, FloatPanel, GridBox, GridSpec, GridStack,\n    HSpacer, Row, Spacer, Swipe, Tabs, VSpacer, WidgetBox,\n)\nfrom .pane import panel  # noqa\nfrom .param import Param, ReactiveExpr  # noqa\nfrom .template import Template  # noqa\nfrom .widgets import indicators, widget  # noqa\n\n__all__ = (\n    \"__version__\",\n    \"Accordion\",\n    \"Card\",\n    \"chat\",\n    \"Column\",\n    \"FlexBox\",\n    \"FloatPanel\",\n    \"GridBox\",\n    \"GridSpec\",\n    \"GridStack\",\n    \"HSpacer\",\n    \"Param\",\n    \"ReactiveExpr\",\n    \"Row\",\n    \"Spacer\",\n    \"Tabs\",\n    \"Template\",\n    \"VSpacer\",\n    \"WidgetBox\",\n    \"bind\",\n    \"cache\",\n    \"config\",\n    \"depends\",\n    \"extension\",\n    \"indicators\",\n    \"interact\",\n    \"ipywidget\",\n    \"layout\",\n    \"links\",\n    \"pane\",\n    \"panel\",\n    \"param\",\n    \"pipeline\",\n    \"rx\",\n    \"serve\",\n    \"state\",\n    \"template\",\n    \"viewable\",\n    \"widgets\",\n    \"widget\"\n)\n", "path": "panel/__init__.py"}]}