def METHOD_NAME(cls_name, method_name):
    if not tf.compat.v1.executing_eagerly_outside_functions():
        error_msg = (
            f"Calling `{cls_name}.{method_name}` in graph mode is not "
            f"supported when the `{cls_name}` instance was constructed with "
            f"eager mode enabled. Please construct your `{cls_name}` instance "
            f"in graph mode or call `{cls_name}.{method_name}` with "
            "eager mode enabled."
        )
        raise ValueError(error_msg)