def _validate_data(estimator, *args, **kwargs):
    """Validate the input data.

    wrapper for sklearn.utils.validation.validate_data or
    BaseEstimator._validate_data depending on the scikit-learn version.

    TODO: remove when minimum scikit-learn version is 1.6
    """
    try:
        # scikit-learn >= 1.6
        from sklearn.utils.validation import validate_data

        return validate_data(estimator, *args, **kwargs)
    except ImportError:
        return estimator._validate_data(*args, **kwargs)
    except:
        raise
Validate the input data.

    wrapper for sklearn.utils.validation.validate_data or
    BaseEstimator._validate_data depending on the scikit-learn version.

    TODO: remove when minimum scikit-learn version is 1.6
    
keras/src/wrappers/fixes.py