def METHOD_NAME(args, ignore_failure=False):
    try:
        orig_out, orig_grad = call_forwards_backwards(f, args)
    except Exception:
        if ignore_failure:
            return
        raise
    # See https://github.com/pytorch/pytorch/pull/98960#issuecomment-1505962215
    if all(x is None for x in orig_grad):
        with assert_raises_regex_fn(RuntimeError, 'does not require grad and does not have a grad_fn'):
            call_forwards_backwards(compiled_f, args)
        return
    msg = (
        "Gradients of the operator are different in eager-mode PyTorch vs "
        "AOTAutograd. This means the operator will have incorrect gradients "
        "underneath torch.compile. This could be because the operator's "
        "backward is incorrectly registered or not traceable or that there "
        "is a bug in AOTAutograd."
    )
    compiled_out, compiled_grad = call_forwards_backwards(compiled_f, args)
    assert_equals_fn(compiled_out, orig_out, msg=outputs_msg)
    assert_equals_fn(compiled_grad, orig_grad, msg=msg)