We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ValueError when calling suggest_categorical with int and str
**Conditions**
- Optuna version: 0.13.0
- Python version: 3.7.3
- OS: Windows 10 Education
- Machine Learning library to be optimized: none

**Code to reproduce**
```
def objective(trial: optuna.Trial):
    x = trial.suggest_categorical("x", [1, "0"])
    print(x)
optuna.create_study( study_name="test_" + now_string(), storage="sqlite:///tmp/example.db").optimize(objective, n_trials=10)
```

**Error messages, stack traces, or logs**

```
Traceback (most recent call last):
  File "C:\Users\imri\github\scoring-model\venv\lib\site-packages\optuna\study.py", line 468, in _run_trial
    result = func(trial)
  File "~\github\scoring-model\tests\TestOptuna.py", line 12, in objective
    x = trial.suggest_categorical("x", [1, "0"])
  File "~\github\scoring-model\venv\lib\site-packages\optuna\trial.py", line 337, in suggest_categorical
    return self._suggest(name, distributions.CategoricalDistribution(choices=choices))
  File "~\github\scoring-model\venv\lib\site-packages\optuna\trial.py", line 457, in _suggest
    return self._set_new_param_or_get_existing(name, param_value, distribution)
  File "~\github\scoring-model\venv\lib\site-packages\optuna\trial.py", line 462, in _set_new_param_or_get_existing
    param_value_in_internal_repr = distribution.to_internal_repr(param_value)
  File "~\github\scoring-model\venv\lib\site-packages\optuna\distributions.py", line 236, in to_internal_repr
    return self.choices.index(param_value_in_external_repr)
ValueError: tuple.index(x): x not in tuple
```



--- 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/random.py`
Content:
```
1 import numpy
2 
3 from optuna import distributions
4 from optuna.samplers.base import BaseSampler
5 from optuna import types
6 
7 if types.TYPE_CHECKING:
8     from typing import Any  # NOQA
9     from typing import Dict  # NOQA
10     from typing import Optional  # NOQA
11 
12     from optuna.distributions import BaseDistribution  # NOQA
13     from optuna.structs import FrozenTrial  # NOQA
14     from optuna.study import InTrialStudy  # NOQA
15 
16 
17 class RandomSampler(BaseSampler):
18     """Sampler using random sampling.
19 
20     Example:
21 
22         .. code::
23 
24             >>> study = optuna.create_study(sampler=RandomSampler())
25             >>> study.optimize(objective, direction='minimize')
26 
27         Args:
28             seed: Seed for random number generator.
29     """
30 
31     def __init__(self, seed=None):
32         # type: (Optional[int]) -> None
33 
34         self.seed = seed
35         self.rng = numpy.random.RandomState(seed)
36 
37     def infer_relative_search_space(self, study, trial):
38         # type: (InTrialStudy, FrozenTrial) -> Dict[str, BaseDistribution]
39 
40         return {}
41 
42     def sample_relative(self, study, trial, search_space):
43         # type: (InTrialStudy, FrozenTrial, Dict[str, BaseDistribution]) -> Dict[str, Any]
44 
45         return {}
46 
47     def sample_independent(self, study, trial, param_name, param_distribution):
48         # type: (InTrialStudy, FrozenTrial, str, distributions.BaseDistribution) -> Any
49         """Please consult the documentation for :func:`BaseSampler.sample_independent`."""
50 
51         if isinstance(param_distribution, distributions.UniformDistribution):
52             return self.rng.uniform(param_distribution.low, param_distribution.high)
53         elif isinstance(param_distribution, distributions.LogUniformDistribution):
54             log_low = numpy.log(param_distribution.low)
55             log_high = numpy.log(param_distribution.high)
56             return float(numpy.exp(self.rng.uniform(log_low, log_high)))
57         elif isinstance(param_distribution, distributions.DiscreteUniformDistribution):
58             q = param_distribution.q
59             r = param_distribution.high - param_distribution.low
60             # [low, high] is shifted to [0, r] to align sampled values at regular intervals.
61             low = 0 - 0.5 * q
62             high = r + 0.5 * q
63             s = self.rng.uniform(low, high)
64             v = numpy.round(s / q) * q + param_distribution.low
65             # v may slightly exceed range due to round-off errors.
66             return float(min(max(v, param_distribution.low), param_distribution.high))
67         elif isinstance(param_distribution, distributions.IntUniformDistribution):
68             # numpy.random.randint includes low but excludes high.
69             return self.rng.randint(param_distribution.low, param_distribution.high + 1)
70         elif isinstance(param_distribution, distributions.CategoricalDistribution):
71             choices = param_distribution.choices
72             return self.rng.choice(choices)
73         else:
74             raise NotImplementedError
75
```
--- 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/random.py b/optuna/samplers/random.py
--- a/optuna/samplers/random.py
+++ b/optuna/samplers/random.py
@@ -69,6 +69,7 @@
             return self.rng.randint(param_distribution.low, param_distribution.high + 1)
         elif isinstance(param_distribution, distributions.CategoricalDistribution):
             choices = param_distribution.choices
-            return self.rng.choice(choices)
+            index = self.rng.randint(0, len(choices))
+            return choices[index]
         else:
             raise NotImplementedError

{"golden_diff": "diff --git a/optuna/samplers/random.py b/optuna/samplers/random.py\n--- a/optuna/samplers/random.py\n+++ b/optuna/samplers/random.py\n@@ -69,6 +69,7 @@\n             return self.rng.randint(param_distribution.low, param_distribution.high + 1)\n         elif isinstance(param_distribution, distributions.CategoricalDistribution):\n             choices = param_distribution.choices\n-            return self.rng.choice(choices)\n+            index = self.rng.randint(0, len(choices))\n+            return choices[index]\n         else:\n             raise NotImplementedError\n", "issue": "ValueError when calling suggest_categorical with int and str\n**Conditions**\r\n- Optuna version: 0.13.0\r\n- Python version: 3.7.3\r\n- OS: Windows 10 Education\r\n- Machine Learning library to be optimized: none\r\n\r\n**Code to reproduce**\r\n```\r\ndef objective(trial: optuna.Trial):\r\n    x = trial.suggest_categorical(\"x\", [1, \"0\"])\r\n    print(x)\r\noptuna.create_study( study_name=\"test_\" + now_string(), storage=\"sqlite:///tmp/example.db\").optimize(objective, n_trials=10)\r\n```\r\n\r\n**Error messages, stack traces, or logs**\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\imri\\github\\scoring-model\\venv\\lib\\site-packages\\optuna\\study.py\", line 468, in _run_trial\r\n    result = func(trial)\r\n  File \"~\\github\\scoring-model\\tests\\TestOptuna.py\", line 12, in objective\r\n    x = trial.suggest_categorical(\"x\", [1, \"0\"])\r\n  File \"~\\github\\scoring-model\\venv\\lib\\site-packages\\optuna\\trial.py\", line 337, in suggest_categorical\r\n    return self._suggest(name, distributions.CategoricalDistribution(choices=choices))\r\n  File \"~\\github\\scoring-model\\venv\\lib\\site-packages\\optuna\\trial.py\", line 457, in _suggest\r\n    return self._set_new_param_or_get_existing(name, param_value, distribution)\r\n  File \"~\\github\\scoring-model\\venv\\lib\\site-packages\\optuna\\trial.py\", line 462, in _set_new_param_or_get_existing\r\n    param_value_in_internal_repr = distribution.to_internal_repr(param_value)\r\n  File \"~\\github\\scoring-model\\venv\\lib\\site-packages\\optuna\\distributions.py\", line 236, in to_internal_repr\r\n    return self.choices.index(param_value_in_external_repr)\r\nValueError: tuple.index(x): x not in tuple\r\n```\r\n\r\n\n", "before_files": [{"content": "import numpy\n\nfrom optuna import distributions\nfrom optuna.samplers.base import BaseSampler\nfrom optuna import types\n\nif types.TYPE_CHECKING:\n    from typing import Any  # NOQA\n    from typing import Dict  # NOQA\n    from typing import Optional  # NOQA\n\n    from optuna.distributions import BaseDistribution  # NOQA\n    from optuna.structs import FrozenTrial  # NOQA\n    from optuna.study import InTrialStudy  # NOQA\n\n\nclass RandomSampler(BaseSampler):\n    \"\"\"Sampler using random sampling.\n\n    Example:\n\n        .. code::\n\n            >>> study = optuna.create_study(sampler=RandomSampler())\n            >>> study.optimize(objective, direction='minimize')\n\n        Args:\n            seed: Seed for random number generator.\n    \"\"\"\n\n    def __init__(self, seed=None):\n        # type: (Optional[int]) -> None\n\n        self.seed = seed\n        self.rng = numpy.random.RandomState(seed)\n\n    def infer_relative_search_space(self, study, trial):\n        # type: (InTrialStudy, FrozenTrial) -> Dict[str, BaseDistribution]\n\n        return {}\n\n    def sample_relative(self, study, trial, search_space):\n        # type: (InTrialStudy, FrozenTrial, Dict[str, BaseDistribution]) -> Dict[str, Any]\n\n        return {}\n\n    def sample_independent(self, study, trial, param_name, param_distribution):\n        # type: (InTrialStudy, FrozenTrial, str, distributions.BaseDistribution) -> Any\n        \"\"\"Please consult the documentation for :func:`BaseSampler.sample_independent`.\"\"\"\n\n        if isinstance(param_distribution, distributions.UniformDistribution):\n            return self.rng.uniform(param_distribution.low, param_distribution.high)\n        elif isinstance(param_distribution, distributions.LogUniformDistribution):\n            log_low = numpy.log(param_distribution.low)\n            log_high = numpy.log(param_distribution.high)\n            return float(numpy.exp(self.rng.uniform(log_low, log_high)))\n        elif isinstance(param_distribution, distributions.DiscreteUniformDistribution):\n            q = param_distribution.q\n            r = param_distribution.high - param_distribution.low\n            # [low, high] is shifted to [0, r] to align sampled values at regular intervals.\n            low = 0 - 0.5 * q\n            high = r + 0.5 * q\n            s = self.rng.uniform(low, high)\n            v = numpy.round(s / q) * q + param_distribution.low\n            # v may slightly exceed range due to round-off errors.\n            return float(min(max(v, param_distribution.low), param_distribution.high))\n        elif isinstance(param_distribution, distributions.IntUniformDistribution):\n            # numpy.random.randint includes low but excludes high.\n            return self.rng.randint(param_distribution.low, param_distribution.high + 1)\n        elif isinstance(param_distribution, distributions.CategoricalDistribution):\n            choices = param_distribution.choices\n            return self.rng.choice(choices)\n        else:\n            raise NotImplementedError\n", "path": "optuna/samplers/random.py"}], "after_files": [{"content": "import numpy\n\nfrom optuna import distributions\nfrom optuna.samplers.base import BaseSampler\nfrom optuna import types\n\nif types.TYPE_CHECKING:\n    from typing import Any  # NOQA\n    from typing import Dict  # NOQA\n    from typing import Optional  # NOQA\n\n    from optuna.distributions import BaseDistribution  # NOQA\n    from optuna.structs import FrozenTrial  # NOQA\n    from optuna.study import InTrialStudy  # NOQA\n\n\nclass RandomSampler(BaseSampler):\n    \"\"\"Sampler using random sampling.\n\n    Example:\n\n        .. code::\n\n            >>> study = optuna.create_study(sampler=RandomSampler())\n            >>> study.optimize(objective, direction='minimize')\n\n        Args:\n            seed: Seed for random number generator.\n    \"\"\"\n\n    def __init__(self, seed=None):\n        # type: (Optional[int]) -> None\n\n        self.seed = seed\n        self.rng = numpy.random.RandomState(seed)\n\n    def infer_relative_search_space(self, study, trial):\n        # type: (InTrialStudy, FrozenTrial) -> Dict[str, BaseDistribution]\n\n        return {}\n\n    def sample_relative(self, study, trial, search_space):\n        # type: (InTrialStudy, FrozenTrial, Dict[str, BaseDistribution]) -> Dict[str, Any]\n\n        return {}\n\n    def sample_independent(self, study, trial, param_name, param_distribution):\n        # type: (InTrialStudy, FrozenTrial, str, distributions.BaseDistribution) -> Any\n        \"\"\"Please consult the documentation for :func:`BaseSampler.sample_independent`.\"\"\"\n\n        if isinstance(param_distribution, distributions.UniformDistribution):\n            return self.rng.uniform(param_distribution.low, param_distribution.high)\n        elif isinstance(param_distribution, distributions.LogUniformDistribution):\n            log_low = numpy.log(param_distribution.low)\n            log_high = numpy.log(param_distribution.high)\n            return float(numpy.exp(self.rng.uniform(log_low, log_high)))\n        elif isinstance(param_distribution, distributions.DiscreteUniformDistribution):\n            q = param_distribution.q\n            r = param_distribution.high - param_distribution.low\n            # [low, high] is shifted to [0, r] to align sampled values at regular intervals.\n            low = 0 - 0.5 * q\n            high = r + 0.5 * q\n            s = self.rng.uniform(low, high)\n            v = numpy.round(s / q) * q + param_distribution.low\n            # v may slightly exceed range due to round-off errors.\n            return float(min(max(v, param_distribution.low), param_distribution.high))\n        elif isinstance(param_distribution, distributions.IntUniformDistribution):\n            # numpy.random.randint includes low but excludes high.\n            return self.rng.randint(param_distribution.low, param_distribution.high + 1)\n        elif isinstance(param_distribution, distributions.CategoricalDistribution):\n            choices = param_distribution.choices\n            index = self.rng.randint(0, len(choices))\n            return choices[index]\n        else:\n            raise NotImplementedError\n", "path": "optuna/samplers/random.py"}]}