We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Reduce warnings in unit tests
### Motivation

The Optuna's unit tests raise many warnings, which make it hard to recognize unexpected warning messages.

### Description

We can filter expected warnings using `@pytest.mark.filterwarnings` or `warnings.simplefilter("ignore")`. Some warnings may be unexpected or unsuitable. We should fix tests or Optuna's codes in such cases.

This issue is contribution-welcome. We welcome any fixes, even how trivial.

### Alternatives (optional)

_No response_

### Additional context (optional)

_No response_

--- 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/visualization/matplotlib/_param_importances.py`
Content:
```
1 from typing import Callable
2 from typing import List
3 from typing import Optional
4 
5 import numpy as np
6 
7 from optuna._experimental import experimental_func
8 from optuna.importance._base import BaseImportanceEvaluator
9 from optuna.logging import get_logger
10 from optuna.study import Study
11 from optuna.trial import FrozenTrial
12 from optuna.visualization._param_importances import _get_importances_info
13 from optuna.visualization._param_importances import _ImportancesInfo
14 from optuna.visualization.matplotlib._matplotlib_imports import _imports
15 
16 
17 if _imports.is_successful():
18     from optuna.visualization.matplotlib._matplotlib_imports import Axes
19     from optuna.visualization.matplotlib._matplotlib_imports import cm
20     from optuna.visualization.matplotlib._matplotlib_imports import plt
21 
22 
23 _logger = get_logger(__name__)
24 
25 
26 AXES_PADDING_RATIO = 1.05
27 
28 
29 @experimental_func("2.2.0")
30 def plot_param_importances(
31     study: Study,
32     evaluator: Optional[BaseImportanceEvaluator] = None,
33     params: Optional[List[str]] = None,
34     *,
35     target: Optional[Callable[[FrozenTrial], float]] = None,
36     target_name: str = "Objective Value",
37 ) -> "Axes":
38     """Plot hyperparameter importances with Matplotlib.
39 
40     .. seealso::
41         Please refer to :func:`optuna.visualization.plot_param_importances` for an example.
42 
43     Example:
44 
45         The following code snippet shows how to plot hyperparameter importances.
46 
47         .. plot::
48 
49             import optuna
50 
51 
52             def objective(trial):
53                 x = trial.suggest_int("x", 0, 2)
54                 y = trial.suggest_float("y", -1.0, 1.0)
55                 z = trial.suggest_float("z", 0.0, 1.5)
56                 return x ** 2 + y ** 3 - z ** 4
57 
58 
59             sampler = optuna.samplers.RandomSampler(seed=10)
60             study = optuna.create_study(sampler=sampler)
61             study.optimize(objective, n_trials=100)
62 
63             optuna.visualization.matplotlib.plot_param_importances(study)
64 
65     Args:
66         study:
67             An optimized study.
68         evaluator:
69             An importance evaluator object that specifies which algorithm to base the importance
70             assessment on.
71             Defaults to
72             :class:`~optuna.importance.FanovaImportanceEvaluator`.
73         params:
74             A list of names of parameters to assess.
75             If :obj:`None`, all parameters that are present in all of the completed trials are
76             assessed.
77         target:
78             A function to specify the value to display. If it is :obj:`None` and ``study`` is being
79             used for single-objective optimization, the objective values are plotted.
80 
81             .. note::
82                 Specify this argument if ``study`` is being used for multi-objective
83                 optimization. For example, to get the hyperparameter importance of the first
84                 objective, use ``target=lambda t: t.values[0]`` for the target parameter.
85         target_name:
86             Target's name to display on the axis label.
87 
88     Returns:
89         A :class:`matplotlib.axes.Axes` object.
90     """
91 
92     _imports.check()
93 
94     importances_info = _get_importances_info(study, evaluator, params, target, target_name)
95     return _get_importances_plot(importances_info)
96 
97 
98 def _get_importances_plot(info: _ImportancesInfo) -> "Axes":
99     # Set up the graph style.
100     plt.style.use("ggplot")  # Use ggplot style sheet for similar outputs to plotly.
101     fig, ax = plt.subplots()
102     ax.set_title("Hyperparameter Importances")
103     ax.set_xlabel(f"Importance for {info.target_name}")
104     ax.set_ylabel("Hyperparameter")
105 
106     param_names = info.param_names
107     pos = np.arange(len(param_names))
108     importance_values = info.importance_values
109 
110     if len(importance_values) == 0:
111         return ax
112 
113     # Draw horizontal bars.
114     ax.barh(
115         pos,
116         importance_values,
117         align="center",
118         color=cm.get_cmap("tab20c")(0),
119         tick_label=param_names,
120     )
121 
122     renderer = fig.canvas.get_renderer()
123     for idx, (val, label) in enumerate(zip(importance_values, info.importance_labels)):
124         text = ax.text(val, idx, label, va="center")
125 
126         # Sometimes horizontal axis needs to be re-scaled
127         # to avoid text going over plot area.
128         bbox = text.get_window_extent(renderer)
129         bbox = bbox.transformed(ax.transData.inverted())
130         _, plot_xmax = ax.get_xlim()
131         bbox_xmax = bbox.xmax
132 
133         if bbox_xmax > plot_xmax:
134             ax.set_xlim(xmax=AXES_PADDING_RATIO * bbox_xmax)
135 
136     return ax
137
```

Path: `optuna/visualization/matplotlib/_matplotlib_imports.py`
Content:
```
1 from packaging import version
2 
3 from optuna._imports import try_import
4 
5 
6 with try_import() as _imports:  # NOQA
7     # TODO(ytknzw): Add specific imports.
8     import matplotlib  # NOQA
9     from matplotlib import __version__ as matplotlib_version
10     from matplotlib import cm  # NOQA
11     from matplotlib import pyplot as plt  # NOQA
12     from matplotlib.axes._axes import Axes  # NOQA
13     from matplotlib.collections import LineCollection  # NOQA
14     from matplotlib.collections import PathCollection  # NOQA
15     from matplotlib.colors import Colormap  # NOQA
16     from matplotlib.contour import ContourSet  # NOQA
17     from matplotlib.patches import Rectangle  # NOQA
18 
19     # TODO(ytknzw): Set precise version.
20     if version.parse(matplotlib_version) < version.parse("3.0.0"):
21         raise ImportError(
22             "Your version of Matplotlib is " + matplotlib_version + " . "
23             "Please install Matplotlib version 3.0.0 or higher. "
24             "Matplotlib can be installed by executing `$ pip install -U matplotlib>=3.0.0`. "
25             "For further information, please refer to the installation guide of Matplotlib. ",
26             name="matplotlib",
27         )
28
```
--- 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/visualization/matplotlib/_matplotlib_imports.py b/optuna/visualization/matplotlib/_matplotlib_imports.py
--- a/optuna/visualization/matplotlib/_matplotlib_imports.py
+++ b/optuna/visualization/matplotlib/_matplotlib_imports.py
@@ -7,7 +7,6 @@
     # TODO(ytknzw): Add specific imports.
     import matplotlib  # NOQA
     from matplotlib import __version__ as matplotlib_version
-    from matplotlib import cm  # NOQA
     from matplotlib import pyplot as plt  # NOQA
     from matplotlib.axes._axes import Axes  # NOQA
     from matplotlib.collections import LineCollection  # NOQA
diff --git a/optuna/visualization/matplotlib/_param_importances.py b/optuna/visualization/matplotlib/_param_importances.py
--- a/optuna/visualization/matplotlib/_param_importances.py
+++ b/optuna/visualization/matplotlib/_param_importances.py
@@ -16,7 +16,6 @@
 
 if _imports.is_successful():
     from optuna.visualization.matplotlib._matplotlib_imports import Axes
-    from optuna.visualization.matplotlib._matplotlib_imports import cm
     from optuna.visualization.matplotlib._matplotlib_imports import plt
 
 
@@ -115,7 +114,7 @@
         pos,
         importance_values,
         align="center",
-        color=cm.get_cmap("tab20c")(0),
+        color=plt.get_cmap("tab20c")(0),
         tick_label=param_names,
     )

{"golden_diff": "diff --git a/optuna/visualization/matplotlib/_matplotlib_imports.py b/optuna/visualization/matplotlib/_matplotlib_imports.py\n--- a/optuna/visualization/matplotlib/_matplotlib_imports.py\n+++ b/optuna/visualization/matplotlib/_matplotlib_imports.py\n@@ -7,7 +7,6 @@\n     # TODO(ytknzw): Add specific imports.\n     import matplotlib  # NOQA\n     from matplotlib import __version__ as matplotlib_version\n-    from matplotlib import cm  # NOQA\n     from matplotlib import pyplot as plt  # NOQA\n     from matplotlib.axes._axes import Axes  # NOQA\n     from matplotlib.collections import LineCollection  # NOQA\ndiff --git a/optuna/visualization/matplotlib/_param_importances.py b/optuna/visualization/matplotlib/_param_importances.py\n--- a/optuna/visualization/matplotlib/_param_importances.py\n+++ b/optuna/visualization/matplotlib/_param_importances.py\n@@ -16,7 +16,6 @@\n \n if _imports.is_successful():\n     from optuna.visualization.matplotlib._matplotlib_imports import Axes\n-    from optuna.visualization.matplotlib._matplotlib_imports import cm\n     from optuna.visualization.matplotlib._matplotlib_imports import plt\n \n \n@@ -115,7 +114,7 @@\n         pos,\n         importance_values,\n         align=\"center\",\n-        color=cm.get_cmap(\"tab20c\")(0),\n+        color=plt.get_cmap(\"tab20c\")(0),\n         tick_label=param_names,\n     )\n", "issue": "Reduce warnings in unit tests\n### Motivation\n\nThe Optuna's unit tests raise many warnings, which make it hard to recognize unexpected warning messages.\n\n### Description\n\nWe can filter expected warnings using `@pytest.mark.filterwarnings` or `warnings.simplefilter(\"ignore\")`. Some warnings may be unexpected or unsuitable. We should fix tests or Optuna's codes in such cases.\r\n\r\nThis issue is contribution-welcome. We welcome any fixes, even how trivial.\n\n### Alternatives (optional)\n\n_No response_\n\n### Additional context (optional)\n\n_No response_\n", "before_files": [{"content": "from typing import Callable\nfrom typing import List\nfrom typing import Optional\n\nimport numpy as np\n\nfrom optuna._experimental import experimental_func\nfrom optuna.importance._base import BaseImportanceEvaluator\nfrom optuna.logging import get_logger\nfrom optuna.study import Study\nfrom optuna.trial import FrozenTrial\nfrom optuna.visualization._param_importances import _get_importances_info\nfrom optuna.visualization._param_importances import _ImportancesInfo\nfrom optuna.visualization.matplotlib._matplotlib_imports import _imports\n\n\nif _imports.is_successful():\n    from optuna.visualization.matplotlib._matplotlib_imports import Axes\n    from optuna.visualization.matplotlib._matplotlib_imports import cm\n    from optuna.visualization.matplotlib._matplotlib_imports import plt\n\n\n_logger = get_logger(__name__)\n\n\nAXES_PADDING_RATIO = 1.05\n\n\n@experimental_func(\"2.2.0\")\ndef plot_param_importances(\n    study: Study,\n    evaluator: Optional[BaseImportanceEvaluator] = None,\n    params: Optional[List[str]] = None,\n    *,\n    target: Optional[Callable[[FrozenTrial], float]] = None,\n    target_name: str = \"Objective Value\",\n) -> \"Axes\":\n    \"\"\"Plot hyperparameter importances with Matplotlib.\n\n    .. seealso::\n        Please refer to :func:`optuna.visualization.plot_param_importances` for an example.\n\n    Example:\n\n        The following code snippet shows how to plot hyperparameter importances.\n\n        .. plot::\n\n            import optuna\n\n\n            def objective(trial):\n                x = trial.suggest_int(\"x\", 0, 2)\n                y = trial.suggest_float(\"y\", -1.0, 1.0)\n                z = trial.suggest_float(\"z\", 0.0, 1.5)\n                return x ** 2 + y ** 3 - z ** 4\n\n\n            sampler = optuna.samplers.RandomSampler(seed=10)\n            study = optuna.create_study(sampler=sampler)\n            study.optimize(objective, n_trials=100)\n\n            optuna.visualization.matplotlib.plot_param_importances(study)\n\n    Args:\n        study:\n            An optimized study.\n        evaluator:\n            An importance evaluator object that specifies which algorithm to base the importance\n            assessment on.\n            Defaults to\n            :class:`~optuna.importance.FanovaImportanceEvaluator`.\n        params:\n            A list of names of parameters to assess.\n            If :obj:`None`, all parameters that are present in all of the completed trials are\n            assessed.\n        target:\n            A function to specify the value to display. If it is :obj:`None` and ``study`` is being\n            used for single-objective optimization, the objective values are plotted.\n\n            .. note::\n                Specify this argument if ``study`` is being used for multi-objective\n                optimization. For example, to get the hyperparameter importance of the first\n                objective, use ``target=lambda t: t.values[0]`` for the target parameter.\n        target_name:\n            Target's name to display on the axis label.\n\n    Returns:\n        A :class:`matplotlib.axes.Axes` object.\n    \"\"\"\n\n    _imports.check()\n\n    importances_info = _get_importances_info(study, evaluator, params, target, target_name)\n    return _get_importances_plot(importances_info)\n\n\ndef _get_importances_plot(info: _ImportancesInfo) -> \"Axes\":\n    # Set up the graph style.\n    plt.style.use(\"ggplot\")  # Use ggplot style sheet for similar outputs to plotly.\n    fig, ax = plt.subplots()\n    ax.set_title(\"Hyperparameter Importances\")\n    ax.set_xlabel(f\"Importance for {info.target_name}\")\n    ax.set_ylabel(\"Hyperparameter\")\n\n    param_names = info.param_names\n    pos = np.arange(len(param_names))\n    importance_values = info.importance_values\n\n    if len(importance_values) == 0:\n        return ax\n\n    # Draw horizontal bars.\n    ax.barh(\n        pos,\n        importance_values,\n        align=\"center\",\n        color=cm.get_cmap(\"tab20c\")(0),\n        tick_label=param_names,\n    )\n\n    renderer = fig.canvas.get_renderer()\n    for idx, (val, label) in enumerate(zip(importance_values, info.importance_labels)):\n        text = ax.text(val, idx, label, va=\"center\")\n\n        # Sometimes horizontal axis needs to be re-scaled\n        # to avoid text going over plot area.\n        bbox = text.get_window_extent(renderer)\n        bbox = bbox.transformed(ax.transData.inverted())\n        _, plot_xmax = ax.get_xlim()\n        bbox_xmax = bbox.xmax\n\n        if bbox_xmax > plot_xmax:\n            ax.set_xlim(xmax=AXES_PADDING_RATIO * bbox_xmax)\n\n    return ax\n", "path": "optuna/visualization/matplotlib/_param_importances.py"}, {"content": "from packaging import version\n\nfrom optuna._imports import try_import\n\n\nwith try_import() as _imports:  # NOQA\n    # TODO(ytknzw): Add specific imports.\n    import matplotlib  # NOQA\n    from matplotlib import __version__ as matplotlib_version\n    from matplotlib import cm  # NOQA\n    from matplotlib import pyplot as plt  # NOQA\n    from matplotlib.axes._axes import Axes  # NOQA\n    from matplotlib.collections import LineCollection  # NOQA\n    from matplotlib.collections import PathCollection  # NOQA\n    from matplotlib.colors import Colormap  # NOQA\n    from matplotlib.contour import ContourSet  # NOQA\n    from matplotlib.patches import Rectangle  # NOQA\n\n    # TODO(ytknzw): Set precise version.\n    if version.parse(matplotlib_version) < version.parse(\"3.0.0\"):\n        raise ImportError(\n            \"Your version of Matplotlib is \" + matplotlib_version + \" . \"\n            \"Please install Matplotlib version 3.0.0 or higher. \"\n            \"Matplotlib can be installed by executing `$ pip install -U matplotlib>=3.0.0`. \"\n            \"For further information, please refer to the installation guide of Matplotlib. \",\n            name=\"matplotlib\",\n        )\n", "path": "optuna/visualization/matplotlib/_matplotlib_imports.py"}], "after_files": [{"content": "from typing import Callable\nfrom typing import List\nfrom typing import Optional\n\nimport numpy as np\n\nfrom optuna._experimental import experimental_func\nfrom optuna.importance._base import BaseImportanceEvaluator\nfrom optuna.logging import get_logger\nfrom optuna.study import Study\nfrom optuna.trial import FrozenTrial\nfrom optuna.visualization._param_importances import _get_importances_info\nfrom optuna.visualization._param_importances import _ImportancesInfo\nfrom optuna.visualization.matplotlib._matplotlib_imports import _imports\n\n\nif _imports.is_successful():\n    from optuna.visualization.matplotlib._matplotlib_imports import Axes\n    from optuna.visualization.matplotlib._matplotlib_imports import plt\n\n\n_logger = get_logger(__name__)\n\n\nAXES_PADDING_RATIO = 1.05\n\n\n@experimental_func(\"2.2.0\")\ndef plot_param_importances(\n    study: Study,\n    evaluator: Optional[BaseImportanceEvaluator] = None,\n    params: Optional[List[str]] = None,\n    *,\n    target: Optional[Callable[[FrozenTrial], float]] = None,\n    target_name: str = \"Objective Value\",\n) -> \"Axes\":\n    \"\"\"Plot hyperparameter importances with Matplotlib.\n\n    .. seealso::\n        Please refer to :func:`optuna.visualization.plot_param_importances` for an example.\n\n    Example:\n\n        The following code snippet shows how to plot hyperparameter importances.\n\n        .. plot::\n\n            import optuna\n\n\n            def objective(trial):\n                x = trial.suggest_int(\"x\", 0, 2)\n                y = trial.suggest_float(\"y\", -1.0, 1.0)\n                z = trial.suggest_float(\"z\", 0.0, 1.5)\n                return x ** 2 + y ** 3 - z ** 4\n\n\n            sampler = optuna.samplers.RandomSampler(seed=10)\n            study = optuna.create_study(sampler=sampler)\n            study.optimize(objective, n_trials=100)\n\n            optuna.visualization.matplotlib.plot_param_importances(study)\n\n    Args:\n        study:\n            An optimized study.\n        evaluator:\n            An importance evaluator object that specifies which algorithm to base the importance\n            assessment on.\n            Defaults to\n            :class:`~optuna.importance.FanovaImportanceEvaluator`.\n        params:\n            A list of names of parameters to assess.\n            If :obj:`None`, all parameters that are present in all of the completed trials are\n            assessed.\n        target:\n            A function to specify the value to display. If it is :obj:`None` and ``study`` is being\n            used for single-objective optimization, the objective values are plotted.\n\n            .. note::\n                Specify this argument if ``study`` is being used for multi-objective\n                optimization. For example, to get the hyperparameter importance of the first\n                objective, use ``target=lambda t: t.values[0]`` for the target parameter.\n        target_name:\n            Target's name to display on the axis label.\n\n    Returns:\n        A :class:`matplotlib.axes.Axes` object.\n    \"\"\"\n\n    _imports.check()\n\n    importances_info = _get_importances_info(study, evaluator, params, target, target_name)\n    return _get_importances_plot(importances_info)\n\n\ndef _get_importances_plot(info: _ImportancesInfo) -> \"Axes\":\n    # Set up the graph style.\n    plt.style.use(\"ggplot\")  # Use ggplot style sheet for similar outputs to plotly.\n    fig, ax = plt.subplots()\n    ax.set_title(\"Hyperparameter Importances\")\n    ax.set_xlabel(f\"Importance for {info.target_name}\")\n    ax.set_ylabel(\"Hyperparameter\")\n\n    param_names = info.param_names\n    pos = np.arange(len(param_names))\n    importance_values = info.importance_values\n\n    if len(importance_values) == 0:\n        return ax\n\n    # Draw horizontal bars.\n    ax.barh(\n        pos,\n        importance_values,\n        align=\"center\",\n        color=plt.get_cmap(\"tab20c\")(0),\n        tick_label=param_names,\n    )\n\n    renderer = fig.canvas.get_renderer()\n    for idx, (val, label) in enumerate(zip(importance_values, info.importance_labels)):\n        text = ax.text(val, idx, label, va=\"center\")\n\n        # Sometimes horizontal axis needs to be re-scaled\n        # to avoid text going over plot area.\n        bbox = text.get_window_extent(renderer)\n        bbox = bbox.transformed(ax.transData.inverted())\n        _, plot_xmax = ax.get_xlim()\n        bbox_xmax = bbox.xmax\n\n        if bbox_xmax > plot_xmax:\n            ax.set_xlim(xmax=AXES_PADDING_RATIO * bbox_xmax)\n\n    return ax\n", "path": "optuna/visualization/matplotlib/_param_importances.py"}, {"content": "from packaging import version\n\nfrom optuna._imports import try_import\n\n\nwith try_import() as _imports:  # NOQA\n    # TODO(ytknzw): Add specific imports.\n    import matplotlib  # NOQA\n    from matplotlib import __version__ as matplotlib_version\n    from matplotlib import pyplot as plt  # NOQA\n    from matplotlib.axes._axes import Axes  # NOQA\n    from matplotlib.collections import LineCollection  # NOQA\n    from matplotlib.collections import PathCollection  # NOQA\n    from matplotlib.colors import Colormap  # NOQA\n    from matplotlib.contour import ContourSet  # NOQA\n    from matplotlib.patches import Rectangle  # NOQA\n\n    # TODO(ytknzw): Set precise version.\n    if version.parse(matplotlib_version) < version.parse(\"3.0.0\"):\n        raise ImportError(\n            \"Your version of Matplotlib is \" + matplotlib_version + \" . \"\n            \"Please install Matplotlib version 3.0.0 or higher. \"\n            \"Matplotlib can be installed by executing `$ pip install -U matplotlib>=3.0.0`. \"\n            \"For further information, please refer to the installation guide of Matplotlib. \",\n            name=\"matplotlib\",\n        )\n", "path": "optuna/visualization/matplotlib/_matplotlib_imports.py"}]}