We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Apply lazy import for `optuna.dashboard`.
Optuna always imports the dependencies of `optuna.dashboard` (e.g., `bokeh`), which makes unnecessary overhead in many use cases. Similar to #334, we can apply lazy import for them.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `optuna/__init__.py`
Content:
```
1 from optuna import dashboard  # NOQA
2 from optuna import distributions  # NOQA
3 from optuna import exceptions  # NOQA
4 from optuna import importance  # NOQA
5 from optuna import integration  # NOQA
6 from optuna import logging  # NOQA
7 from optuna import pruners  # NOQA
8 from optuna import samplers  # NOQA
9 from optuna import storages  # NOQA
10 from optuna import structs  # NOQA
11 from optuna import study  # NOQA
12 from optuna import trial  # NOQA
13 from optuna import version  # NOQA
14 from optuna import visualization  # NOQA
15 
16 from optuna.study import create_study  # NOQA
17 from optuna.study import delete_study  # NOQA
18 from optuna.study import get_all_study_summaries  # NOQA
19 from optuna.study import load_study  # NOQA
20 from optuna.study import Study  # NOQA
21 from optuna.trial import Trial  # NOQA
22 from optuna.version import __version__  # NOQA
23
```
--- 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/optuna/__init__.py b/optuna/__init__.py
--- a/optuna/__init__.py
+++ b/optuna/__init__.py
@@ -1,4 +1,6 @@
-from optuna import dashboard  # NOQA
+import importlib
+import types
+
 from optuna import distributions  # NOQA
 from optuna import exceptions  # NOQA
 from optuna import importance  # NOQA
@@ -20,3 +22,37 @@
 from optuna.study import Study  # NOQA
 from optuna.trial import Trial  # NOQA
 from optuna.version import __version__  # NOQA
+from optuna.type_checking import TYPE_CHECKING  # NOQA
+
+
+if TYPE_CHECKING:
+    from optuna import dashboard  # NOQA
+else:
+    from typing import Any
+
+    class _LazyImport(types.ModuleType):
+        """Module wrapper for lazy import.
+
+        This class wraps specified module and lazily import it when they are actually accessed.
+        Otherwise, `import optuna` becomes slower because it imports all submodules and
+        their dependencies (e.g., bokeh) all at once.
+        Within this project's usage, importlib override this module's attribute on the first
+        access and the imported submodule is directly accessed from the second access.
+
+        Args:
+            name: Name of module to apply lazy import.
+        """
+
+        def __init__(self, name: str) -> None:
+            super(_LazyImport, self).__init__(name)
+            self._name = name
+
+        def _load(self) -> types.ModuleType:
+            module = importlib.import_module(self._name)
+            self.__dict__.update(module.__dict__)
+            return module
+
+        def __getattr__(self, item: str) -> Any:
+            return getattr(self._load(), item)
+
+    dashboard = _LazyImport("optuna.dashboard")

{"golden_diff": "diff --git a/optuna/__init__.py b/optuna/__init__.py\n--- a/optuna/__init__.py\n+++ b/optuna/__init__.py\n@@ -1,4 +1,6 @@\n-from optuna import dashboard  # NOQA\n+import importlib\n+import types\n+\n from optuna import distributions  # NOQA\n from optuna import exceptions  # NOQA\n from optuna import importance  # NOQA\n@@ -20,3 +22,37 @@\n from optuna.study import Study  # NOQA\n from optuna.trial import Trial  # NOQA\n from optuna.version import __version__  # NOQA\n+from optuna.type_checking import TYPE_CHECKING  # NOQA\n+\n+\n+if TYPE_CHECKING:\n+    from optuna import dashboard  # NOQA\n+else:\n+    from typing import Any\n+\n+    class _LazyImport(types.ModuleType):\n+        \"\"\"Module wrapper for lazy import.\n+\n+        This class wraps specified module and lazily import it when they are actually accessed.\n+        Otherwise, `import optuna` becomes slower because it imports all submodules and\n+        their dependencies (e.g., bokeh) all at once.\n+        Within this project's usage, importlib override this module's attribute on the first\n+        access and the imported submodule is directly accessed from the second access.\n+\n+        Args:\n+            name: Name of module to apply lazy import.\n+        \"\"\"\n+\n+        def __init__(self, name: str) -> None:\n+            super(_LazyImport, self).__init__(name)\n+            self._name = name\n+\n+        def _load(self) -> types.ModuleType:\n+            module = importlib.import_module(self._name)\n+            self.__dict__.update(module.__dict__)\n+            return module\n+\n+        def __getattr__(self, item: str) -> Any:\n+            return getattr(self._load(), item)\n+\n+    dashboard = _LazyImport(\"optuna.dashboard\")\n", "issue": "Apply lazy import for `optuna.dashboard`.\nOptuna always imports the dependencies of `optuna.dashboard` (e.g., `bokeh`), which makes unnecessary overhead in many use cases. Similar to #334, we can apply lazy import for them.\n", "before_files": [{"content": "from optuna import dashboard  # NOQA\nfrom optuna import distributions  # NOQA\nfrom optuna import exceptions  # NOQA\nfrom optuna import importance  # NOQA\nfrom optuna import integration  # NOQA\nfrom optuna import logging  # NOQA\nfrom optuna import pruners  # NOQA\nfrom optuna import samplers  # NOQA\nfrom optuna import storages  # NOQA\nfrom optuna import structs  # NOQA\nfrom optuna import study  # NOQA\nfrom optuna import trial  # NOQA\nfrom optuna import version  # NOQA\nfrom optuna import visualization  # NOQA\n\nfrom optuna.study import create_study  # NOQA\nfrom optuna.study import delete_study  # NOQA\nfrom optuna.study import get_all_study_summaries  # NOQA\nfrom optuna.study import load_study  # NOQA\nfrom optuna.study import Study  # NOQA\nfrom optuna.trial import Trial  # NOQA\nfrom optuna.version import __version__  # NOQA\n", "path": "optuna/__init__.py"}], "after_files": [{"content": "import importlib\nimport types\n\nfrom optuna import distributions  # NOQA\nfrom optuna import exceptions  # NOQA\nfrom optuna import importance  # NOQA\nfrom optuna import integration  # NOQA\nfrom optuna import logging  # NOQA\nfrom optuna import pruners  # NOQA\nfrom optuna import samplers  # NOQA\nfrom optuna import storages  # NOQA\nfrom optuna import structs  # NOQA\nfrom optuna import study  # NOQA\nfrom optuna import trial  # NOQA\nfrom optuna import version  # NOQA\nfrom optuna import visualization  # NOQA\n\nfrom optuna.study import create_study  # NOQA\nfrom optuna.study import delete_study  # NOQA\nfrom optuna.study import get_all_study_summaries  # NOQA\nfrom optuna.study import load_study  # NOQA\nfrom optuna.study import Study  # NOQA\nfrom optuna.trial import Trial  # NOQA\nfrom optuna.version import __version__  # NOQA\nfrom optuna.type_checking import TYPE_CHECKING  # NOQA\n\n\nif TYPE_CHECKING:\n    from optuna import dashboard  # NOQA\nelse:\n    from typing import Any\n\n    class _LazyImport(types.ModuleType):\n        \"\"\"Module wrapper for lazy import.\n\n        This class wraps specified module and lazily import it when they are actually accessed.\n        Otherwise, `import optuna` becomes slower because it imports all submodules and\n        their dependencies (e.g., bokeh) all at once.\n        Within this project's usage, importlib override this module's attribute on the first\n        access and the imported submodule is directly accessed from the second access.\n\n        Args:\n            name: Name of module to apply lazy import.\n        \"\"\"\n\n        def __init__(self, name: str) -> None:\n            super(_LazyImport, self).__init__(name)\n            self._name = name\n\n        def _load(self) -> types.ModuleType:\n            module = importlib.import_module(self._name)\n            self.__dict__.update(module.__dict__)\n            return module\n\n        def __getattr__(self, item: str) -> Any:\n            return getattr(self._load(), item)\n\n    dashboard = _LazyImport(\"optuna.dashboard\")\n", "path": "optuna/__init__.py"}]}