def _fit_context(*, prefer_skip_nested_validation):
        """Decorator to run the fit methods of estimators within context managers."""

        def decorator(fit_method):
            @functools.wraps(fit_method)
            def wrapper(estimator, *args, **kwargs):
                estimator._validate_params()
                return fit_method(estimator, *args, **kwargs)

            return wrapper

        return decorator
Decorator to run the fit methods of estimators within context managers.
imblearn/utils/_sklearn_compat.py