Repository: optuna/optuna

Issue:
Out of bounds error when using CmaEsSampler
I cannot run the sample code for the CME-ES algorithm provided [here](https://optuna.readthedocs.io/en/stable/reference/samplers.html). It runs for one trial and then it outputs an out of bounds error.

## Expected behavior

To perform optimization of the given objective function using the CMA-ES algorithm.

## Environment

- Optuna version: 1.4.0
- Python version: 3.6.8
- OS: Windows 10 x64
- Other libraries and their versions: conda 4.8.2

## Error messages, stack traces, or logs

```
Traceback (most recent call last):

  File "C:\Users\User\work\untitled0.py", line 10, in <module>
    study.optimize(objective, n_trials=20)

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\study.py", line 334, in optimize
    func, n_trials, timeout, catch, callbacks, gc_after_trial, None

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\study.py", line 648, in _optimize_sequential
    self._run_trial_and_callbacks(func, catch, callbacks, gc_after_trial)

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\study.py", line 678, in _run_trial_and_callbacks
    trial = self._run_trial(func, catch, gc_after_trial)

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\study.py", line 695, in _run_trial
    trial = trial_module.Trial(self, trial_id)

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\trial.py", line 409, in __init__
    self._init_relative_params()

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\trial.py", line 420, in _init_relative_params
    self.study, trial, self.relative_search_space

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\samplers\cmaes.py", line 175, in sample_relative
    optimizer = self._restore_or_init_optimizer(completed_trials, search_space, ordered_keys)

  File "C:\Users\User\Anaconda3\envs\base_clone\lib\site-packages\optuna\samplers\cmaes.py", line 251, in _restore_or_init_optimizer
    seed=self._cma_rng.randint(1, 2 ** 32),

  File "mtrand.pyx", line 745, in numpy.random.mtrand.RandomState.randint

  File "_bounded_integers.pyx", line 1360, in numpy.random._bounded_integers._rand_int32

ValueError: high is out of bounds for int32
```

## Steps to reproduce

1. Run the code provided below.

## Reproducible examples

```python
import optuna

def objective(trial):
    x = trial.suggest_uniform('x', -1, 1)
    y = trial.suggest_int('y', -1, 1)
    return x ** 2 + y

sampler = optuna.samplers.CmaEsSampler()
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=20)
```



Discussion:

Resolving patch:
diff --git a/optuna/samplers/cmaes.py b/optuna/samplers/cmaes.py
--- a/optuna/samplers/cmaes.py
+++ b/optuna/samplers/cmaes.py
@@ -248,7 +248,7 @@ def _restore_or_init_optimizer(
             mean=mean,
             sigma=sigma0,
             bounds=bounds,
-            seed=self._cma_rng.randint(1, 2 ** 32),
+            seed=self._cma_rng.randint(1, 2 ** 31 - 2),
             n_max_resampling=10 * n_dimension,
         )
 


Test patch: