We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`PartialFixedSampler` does not handle `None` correctly
### Expected behavior

In the following codes, "x" should be `None`. But sometimes 0 is sampled.

```python
import optuna

def objective(trial):
    x = trial.suggest_categorical("x", (None, 0))
    return 0

tpe = optuna.samplers.TPESampler()
sampler = optuna.samplers.PartialFixedSampler({"x": None}, tpe)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=10)
```

```
[I 2022-11-06 14:47:19,010] A new study created in memory with name: no-name-4c144572-cd3b-442a-99d8-962f8401367a
[I 2022-11-06 14:47:19,013] Trial 0 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,013] Trial 1 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,014] Trial 2 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,014] Trial 3 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,014] Trial 4 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,015] Trial 5 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,015] Trial 6 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,015] Trial 7 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,016] Trial 8 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
[I 2022-11-06 14:47:19,016] Trial 9 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.
```

### Environment

- Optuna version:3.1.0.dev
- Python version:3.8.6
- OS:macOS-10.16-x86_64-i386-64bit
- (Optional) Other libraries and their versions:


### Error messages, stack traces, or logs

See `Expected behavior`


### Steps to reproduce

See `Expected behavior`

### Additional context (optional)

This code is buggy when param_value is `None`.

https://github.com/optuna/optuna/blob/c155cea56c9fb0f4752a9838e2518d416719f949/optuna/samplers/_partial_fixed.py#L94-L113

--- 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/samplers/_partial_fixed.py`
Content:
```
1 from typing import Any
2 from typing import Dict
3 from typing import Optional
4 from typing import Sequence
5 import warnings
6 
7 from optuna._experimental import experimental_class
8 from optuna.distributions import BaseDistribution
9 from optuna.samplers import BaseSampler
10 from optuna.study import Study
11 from optuna.trial import FrozenTrial
12 from optuna.trial import TrialState
13 
14 
15 @experimental_class("2.4.0")
16 class PartialFixedSampler(BaseSampler):
17     """Sampler with partially fixed parameters.
18 
19         .. versionadded:: 2.4.0
20 
21     Example:
22 
23         After several steps of optimization, you can fix the value of ``y`` and re-optimize it.
24 
25         .. testcode::
26 
27             import optuna
28 
29 
30             def objective(trial):
31                 x = trial.suggest_float("x", -1, 1)
32                 y = trial.suggest_int("y", -1, 1)
33                 return x**2 + y
34 
35 
36             study = optuna.create_study()
37             study.optimize(objective, n_trials=10)
38 
39             best_params = study.best_params
40             fixed_params = {"y": best_params["y"]}
41             partial_sampler = optuna.samplers.PartialFixedSampler(fixed_params, study.sampler)
42 
43             study.sampler = partial_sampler
44             study.optimize(objective, n_trials=10)
45 
46     Args:
47 
48         fixed_params:
49             A dictionary of parameters to be fixed.
50 
51         base_sampler:
52             A sampler which samples unfixed parameters.
53 
54     """
55 
56     def __init__(self, fixed_params: Dict[str, Any], base_sampler: BaseSampler) -> None:
57         self._fixed_params = fixed_params
58         self._base_sampler = base_sampler
59 
60     def reseed_rng(self) -> None:
61         self._base_sampler.reseed_rng()
62 
63     def infer_relative_search_space(
64         self, study: Study, trial: FrozenTrial
65     ) -> Dict[str, BaseDistribution]:
66 
67         search_space = self._base_sampler.infer_relative_search_space(study, trial)
68 
69         # Remove fixed params from relative search space to return fixed values.
70         for param_name in self._fixed_params.keys():
71             if param_name in search_space:
72                 del search_space[param_name]
73 
74         return search_space
75 
76     def sample_relative(
77         self,
78         study: Study,
79         trial: FrozenTrial,
80         search_space: Dict[str, BaseDistribution],
81     ) -> Dict[str, Any]:
82 
83         # Fixed params are never sampled here.
84         return self._base_sampler.sample_relative(study, trial, search_space)
85 
86     def sample_independent(
87         self,
88         study: Study,
89         trial: FrozenTrial,
90         param_name: str,
91         param_distribution: BaseDistribution,
92     ) -> Any:
93 
94         # If param_name isn't in self._fixed_params.keys(), param_value is set to None.
95         param_value = self._fixed_params.get(param_name)
96 
97         if param_value is None:
98             # Unfixed params are sampled here.
99             return self._base_sampler.sample_independent(
100                 study, trial, param_name, param_distribution
101             )
102         else:
103             # Fixed params are sampled here.
104             # Check if a parameter value is contained in the range of this distribution.
105             param_value_in_internal_repr = param_distribution.to_internal_repr(param_value)
106             contained = param_distribution._contains(param_value_in_internal_repr)
107 
108             if not contained:
109                 warnings.warn(
110                     f"Fixed parameter '{param_name}' with value {param_value} is out of range "
111                     f"for distribution {param_distribution}."
112                 )
113             return param_value
114 
115     def after_trial(
116         self,
117         study: Study,
118         trial: FrozenTrial,
119         state: TrialState,
120         values: Optional[Sequence[float]],
121     ) -> None:
122 
123         self._base_sampler.after_trial(study, trial, state, values)
124
```
--- 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/samplers/_partial_fixed.py b/optuna/samplers/_partial_fixed.py
--- a/optuna/samplers/_partial_fixed.py
+++ b/optuna/samplers/_partial_fixed.py
@@ -91,10 +91,7 @@
         param_distribution: BaseDistribution,
     ) -> Any:
 
-        # If param_name isn't in self._fixed_params.keys(), param_value is set to None.
-        param_value = self._fixed_params.get(param_name)
-
-        if param_value is None:
+        if param_name not in self._fixed_params:
             # Unfixed params are sampled here.
             return self._base_sampler.sample_independent(
                 study, trial, param_name, param_distribution
@@ -102,6 +99,8 @@
         else:
             # Fixed params are sampled here.
             # Check if a parameter value is contained in the range of this distribution.
+            param_value = self._fixed_params[param_name]
+
             param_value_in_internal_repr = param_distribution.to_internal_repr(param_value)
             contained = param_distribution._contains(param_value_in_internal_repr)

{"golden_diff": "diff --git a/optuna/samplers/_partial_fixed.py b/optuna/samplers/_partial_fixed.py\n--- a/optuna/samplers/_partial_fixed.py\n+++ b/optuna/samplers/_partial_fixed.py\n@@ -91,10 +91,7 @@\n         param_distribution: BaseDistribution,\n     ) -> Any:\n \n-        # If param_name isn't in self._fixed_params.keys(), param_value is set to None.\n-        param_value = self._fixed_params.get(param_name)\n-\n-        if param_value is None:\n+        if param_name not in self._fixed_params:\n             # Unfixed params are sampled here.\n             return self._base_sampler.sample_independent(\n                 study, trial, param_name, param_distribution\n@@ -102,6 +99,8 @@\n         else:\n             # Fixed params are sampled here.\n             # Check if a parameter value is contained in the range of this distribution.\n+            param_value = self._fixed_params[param_name]\n+\n             param_value_in_internal_repr = param_distribution.to_internal_repr(param_value)\n             contained = param_distribution._contains(param_value_in_internal_repr)\n", "issue": "`PartialFixedSampler` does not handle `None` correctly\n### Expected behavior\r\n\r\nIn the following codes, \"x\" should be `None`. But sometimes 0 is sampled.\r\n\r\n```python\r\nimport optuna\r\n\r\ndef objective(trial):\r\n    x = trial.suggest_categorical(\"x\", (None, 0))\r\n    return 0\r\n\r\ntpe = optuna.samplers.TPESampler()\r\nsampler = optuna.samplers.PartialFixedSampler({\"x\": None}, tpe)\r\nstudy = optuna.create_study(sampler=sampler)\r\nstudy.optimize(objective, n_trials=10)\r\n```\r\n\r\n```\r\n[I 2022-11-06 14:47:19,010] A new study created in memory with name: no-name-4c144572-cd3b-442a-99d8-962f8401367a\r\n[I 2022-11-06 14:47:19,013] Trial 0 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,013] Trial 1 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,014] Trial 2 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,014] Trial 3 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,014] Trial 4 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,015] Trial 5 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,015] Trial 6 finished with value: 0.0 and parameters: {'x': None}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,015] Trial 7 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,016] Trial 8 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n[I 2022-11-06 14:47:19,016] Trial 9 finished with value: 0.0 and parameters: {'x': 0}. Best is trial 0 with value: 0.0.\r\n```\r\n\r\n### Environment\r\n\r\n- Optuna version:3.1.0.dev\r\n- Python version:3.8.6\r\n- OS:macOS-10.16-x86_64-i386-64bit\r\n- (Optional) Other libraries and their versions:\r\n\r\n\r\n### Error messages, stack traces, or logs\r\n\r\nSee `Expected behavior`\r\n\r\n\r\n### Steps to reproduce\r\n\r\nSee `Expected behavior`\r\n\r\n### Additional context (optional)\r\n\r\nThis code is buggy when param_value is `None`.\r\n\r\nhttps://github.com/optuna/optuna/blob/c155cea56c9fb0f4752a9838e2518d416719f949/optuna/samplers/_partial_fixed.py#L94-L113\n", "before_files": [{"content": "from typing import Any\nfrom typing import Dict\nfrom typing import Optional\nfrom typing import Sequence\nimport warnings\n\nfrom optuna._experimental import experimental_class\nfrom optuna.distributions import BaseDistribution\nfrom optuna.samplers import BaseSampler\nfrom optuna.study import Study\nfrom optuna.trial import FrozenTrial\nfrom optuna.trial import TrialState\n\n\n@experimental_class(\"2.4.0\")\nclass PartialFixedSampler(BaseSampler):\n    \"\"\"Sampler with partially fixed parameters.\n\n        .. versionadded:: 2.4.0\n\n    Example:\n\n        After several steps of optimization, you can fix the value of ``y`` and re-optimize it.\n\n        .. testcode::\n\n            import optuna\n\n\n            def objective(trial):\n                x = trial.suggest_float(\"x\", -1, 1)\n                y = trial.suggest_int(\"y\", -1, 1)\n                return x**2 + y\n\n\n            study = optuna.create_study()\n            study.optimize(objective, n_trials=10)\n\n            best_params = study.best_params\n            fixed_params = {\"y\": best_params[\"y\"]}\n            partial_sampler = optuna.samplers.PartialFixedSampler(fixed_params, study.sampler)\n\n            study.sampler = partial_sampler\n            study.optimize(objective, n_trials=10)\n\n    Args:\n\n        fixed_params:\n            A dictionary of parameters to be fixed.\n\n        base_sampler:\n            A sampler which samples unfixed parameters.\n\n    \"\"\"\n\n    def __init__(self, fixed_params: Dict[str, Any], base_sampler: BaseSampler) -> None:\n        self._fixed_params = fixed_params\n        self._base_sampler = base_sampler\n\n    def reseed_rng(self) -> None:\n        self._base_sampler.reseed_rng()\n\n    def infer_relative_search_space(\n        self, study: Study, trial: FrozenTrial\n    ) -> Dict[str, BaseDistribution]:\n\n        search_space = self._base_sampler.infer_relative_search_space(study, trial)\n\n        # Remove fixed params from relative search space to return fixed values.\n        for param_name in self._fixed_params.keys():\n            if param_name in search_space:\n                del search_space[param_name]\n\n        return search_space\n\n    def sample_relative(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        search_space: Dict[str, BaseDistribution],\n    ) -> Dict[str, Any]:\n\n        # Fixed params are never sampled here.\n        return self._base_sampler.sample_relative(study, trial, search_space)\n\n    def sample_independent(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        param_name: str,\n        param_distribution: BaseDistribution,\n    ) -> Any:\n\n        # If param_name isn't in self._fixed_params.keys(), param_value is set to None.\n        param_value = self._fixed_params.get(param_name)\n\n        if param_value is None:\n            # Unfixed params are sampled here.\n            return self._base_sampler.sample_independent(\n                study, trial, param_name, param_distribution\n            )\n        else:\n            # Fixed params are sampled here.\n            # Check if a parameter value is contained in the range of this distribution.\n            param_value_in_internal_repr = param_distribution.to_internal_repr(param_value)\n            contained = param_distribution._contains(param_value_in_internal_repr)\n\n            if not contained:\n                warnings.warn(\n                    f\"Fixed parameter '{param_name}' with value {param_value} is out of range \"\n                    f\"for distribution {param_distribution}.\"\n                )\n            return param_value\n\n    def after_trial(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        state: TrialState,\n        values: Optional[Sequence[float]],\n    ) -> None:\n\n        self._base_sampler.after_trial(study, trial, state, values)\n", "path": "optuna/samplers/_partial_fixed.py"}], "after_files": [{"content": "from typing import Any\nfrom typing import Dict\nfrom typing import Optional\nfrom typing import Sequence\nimport warnings\n\nfrom optuna._experimental import experimental_class\nfrom optuna.distributions import BaseDistribution\nfrom optuna.samplers import BaseSampler\nfrom optuna.study import Study\nfrom optuna.trial import FrozenTrial\nfrom optuna.trial import TrialState\n\n\n@experimental_class(\"2.4.0\")\nclass PartialFixedSampler(BaseSampler):\n    \"\"\"Sampler with partially fixed parameters.\n\n        .. versionadded:: 2.4.0\n\n    Example:\n\n        After several steps of optimization, you can fix the value of ``y`` and re-optimize it.\n\n        .. testcode::\n\n            import optuna\n\n\n            def objective(trial):\n                x = trial.suggest_float(\"x\", -1, 1)\n                y = trial.suggest_int(\"y\", -1, 1)\n                return x**2 + y\n\n\n            study = optuna.create_study()\n            study.optimize(objective, n_trials=10)\n\n            best_params = study.best_params\n            fixed_params = {\"y\": best_params[\"y\"]}\n            partial_sampler = optuna.samplers.PartialFixedSampler(fixed_params, study.sampler)\n\n            study.sampler = partial_sampler\n            study.optimize(objective, n_trials=10)\n\n    Args:\n\n        fixed_params:\n            A dictionary of parameters to be fixed.\n\n        base_sampler:\n            A sampler which samples unfixed parameters.\n\n    \"\"\"\n\n    def __init__(self, fixed_params: Dict[str, Any], base_sampler: BaseSampler) -> None:\n        self._fixed_params = fixed_params\n        self._base_sampler = base_sampler\n\n    def reseed_rng(self) -> None:\n        self._base_sampler.reseed_rng()\n\n    def infer_relative_search_space(\n        self, study: Study, trial: FrozenTrial\n    ) -> Dict[str, BaseDistribution]:\n\n        search_space = self._base_sampler.infer_relative_search_space(study, trial)\n\n        # Remove fixed params from relative search space to return fixed values.\n        for param_name in self._fixed_params.keys():\n            if param_name in search_space:\n                del search_space[param_name]\n\n        return search_space\n\n    def sample_relative(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        search_space: Dict[str, BaseDistribution],\n    ) -> Dict[str, Any]:\n\n        # Fixed params are never sampled here.\n        return self._base_sampler.sample_relative(study, trial, search_space)\n\n    def sample_independent(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        param_name: str,\n        param_distribution: BaseDistribution,\n    ) -> Any:\n\n        if param_name not in self._fixed_params:\n            # Unfixed params are sampled here.\n            return self._base_sampler.sample_independent(\n                study, trial, param_name, param_distribution\n            )\n        else:\n            # Fixed params are sampled here.\n            # Check if a parameter value is contained in the range of this distribution.\n            param_value = self._fixed_params[param_name]\n\n            param_value_in_internal_repr = param_distribution.to_internal_repr(param_value)\n            contained = param_distribution._contains(param_value_in_internal_repr)\n\n            if not contained:\n                warnings.warn(\n                    f\"Fixed parameter '{param_name}' with value {param_value} is out of range \"\n                    f\"for distribution {param_distribution}.\"\n                )\n            return param_value\n\n    def after_trial(\n        self,\n        study: Study,\n        trial: FrozenTrial,\n        state: TrialState,\n        values: Optional[Sequence[float]],\n    ) -> None:\n\n        self._base_sampler.after_trial(study, trial, state, values)\n", "path": "optuna/samplers/_partial_fixed.py"}]}