def _estimator_has(attr):
    """Checks if the model has a given attribute.

    Meant to be used along with `sklearn.utils.metaestimators.available_if`

    Parameters
    ----------
    attr : str
        The attribute to check the calling object for

    Returns
    -------
    fn : callable
        A function that will either raise an `AttributeError` if the attribute
        does not exist, or True if it does.
    """
    def check(self):
        # raise original `AttributeError` if `attr` does not exist
        getattr(self, attr)
        return True

    return check