# Buggy code
def get_extras_require():
    # type: () -> Dict[str, List[str]]

    requirements = {
        "checking": [
            "autopep8",
            "hacking",
            "mypy",
        ],
        "codecov": [
            "codecov",
            "pytest-cov",
        ],
        "doctest": [
            "pandas",
            "scikit-learn>=0.19.0",
        ],
        "document": [
            "lightgbm",
            "sphinx",
            "sphinx_rtd_theme",
        ],
        "example": [
            "catboost",
            "chainer",
            "lightgbm",
            "mlflow",
            "mxnet",
            "scikit-image",
            "scikit-learn",
            "xgboost",
        ]
        + (["fastai<2"] if (3, 5) < sys.version_info[:2] < (3, 8) else [])
        + (
            [
                "dask[dataframe]",
                "dask-ml",
                "keras",
                "pytorch-ignite",
                "pytorch-lightning",
                # TODO(Yanase): Update examples to support TensorFlow 2.0.
                # See https://github.com/optuna/optuna/issues/565 for further details.
                "tensorflow<2.0.0",
                "torch",
                "torchvision",
            ]
            if sys.version_info[:2] < (3, 8)
            else []
        ),
        "testing": [
            "bokeh",
            "chainer>=5.0.0",
            "cma",
            "lightgbm",
            "mock",
            "mpi4py",
            "mxnet",
            "pandas",
            "plotly>=4.0.0",
            "pytest",
            "scikit-learn>=0.19.0",
            "scikit-optimize",
            "xgboost",
        ]
        + (["fastai<2"] if (3, 5) < sys.version_info[:2] < (3, 8) else [])
        + (
            [
                "keras",
                "pytorch-ignite",
                "pytorch-lightning",
                "tensorflow",
                "tensorflow-datasets",
                "torch",
                "torchvision",
            ]
            if sys.version_info[:2] < (3, 8)
            else []
        ),
    }

    return requirements


# Traceback (ImportError)
import sklearn
import optuna.integration.sklearn

# The following line raises import error even if sklearn has been installed.
optuna.integration.sklearn._check_sklearn_availability()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/optuna/integration/sklearn.py", line 65, in _check_sklearn_availability
raise ImportError(
ImportError: scikit-learn is not available. Please install scikit-learn to use this feature. scikit-learn can be installed by executing `$ pip install scikit-learn>=0.19.0`. For further information, please refer to the installation guide of scikit-learn. (The actual import error is as follows: cannot import name '_index_param_value' from 'sklearn.model_selection._validation' (/usr/local/lib/python3.8/site-packages/sklearn/model_selection/_validation.py))

# The actual cause of the above error.
from sklearn.model_selection._validation import _index_param_value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name '_index_param_value' from 'sklearn.model_selection._validation' (/usr/local/lib/python3.7/site-packages/sklearn/model_selection/_validation.py)

# Fixed code
def get_extras_require():
    # type: () -> Dict[str, List[str]]

    requirements = {
        "checking": [
            "autopep8",
            "hacking",
            "mypy",
        ],
        "codecov": [
            "codecov",
            "pytest-cov",
        ],
        "doctest": [
            "pandas",
            # TODO(Yanase): Update sklearn integration to support v0.22.1 or newer.
            # See https://github.com/optuna/optuna/issues/825 for further details.
            "scikit-learn>=0.19.0,<=0.22.0",
        ],
        "document": [
            "lightgbm",
            "sphinx",
            "sphinx_rtd_theme",
        ],
        "example": [
            "catboost",
            "chainer",
            "lightgbm",
            "mlflow",
            "mxnet",
            "scikit-image",
            # TODO(Yanase): Update sklearn integration to support v0.22.1 or newer.
            # See https://github.com/optuna/optuna/issues/825 for further details.
            "scikit-learn<=0.22.0",
            "xgboost",
        ]
        + (["fastai<2"] if (3, 5) < sys.version_info[:2] < (3, 8) else [])
        + (
            [
                "dask[dataframe]",
                "dask-ml",
                "keras",
                "pytorch-ignite",
                "pytorch-lightning",
                # TODO(Yanase): Update examples to support TensorFlow 2.0.
                # See https://github.com/optuna/optuna/issues/565 for further details.
                "tensorflow<2.0.0",
                "torch",
                "torchvision",
            ]
            if sys.version_info[:2] < (3, 8)
            else []
        ),
        "testing": [
            "bokeh",
            "chainer>=5.0.0",
            "cma",
            "lightgbm",
            "mock",
            "mpi4py",
            "mxnet",
            "pandas",
            "plotly>=4.0.0",
            "pytest",
            # TODO(Yanase): Update sklearn integration to support v0.22.1 or newer.
            # See https://github.com/optuna/optuna/issues/825 for further details.
            "scikit-learn>=0.19.0,<=0.22.0",
            "scikit-optimize",
            "xgboost",
        ]
        + (["fastai<2"] if (3, 5) < sys.version_info[:2] < (3, 8) else [])
        + (
            [
                "keras",
                "pytorch-ignite",
                "pytorch-lightning",
                "tensorflow",
                "tensorflow-datasets",
                "torch",
                "torchvision",
            ]
            if sys.version_info[:2] < (3, 8)
            else []
        ),
    }

    return requirements