def METHOD_NAME(gradient):
    if (
        gradient is not None
        and hasattr(gradient, "_derivative_type")
        and gradient._derivative_type != DerivativeType.REAL
    ):
        warnings.warn(
            "A gradient instance with a setting for calculating imaginary part of "
            "the gradient was provided. This variational principle requires the"
            "real part. The setting to real was changed automatically."
        )
        gradient._derivative_type = DerivativeType.REAL