Iteratively call a program until a metric passes or attempts are exhausted.
:n is how many attempts it makes (3 by default), as N is in DSPy's
dspy.Refine and in Imp.Predict.BestOfN.
With no explicit :feedback_fn, Refine uses the wrapped program's LM to ask
for bounded repair advice after a below-threshold attempt. The advice is
passed to the next attempt as :hint_. An explicit callback selects custom
feedback generation and takes precedence over automatic feedback.
Like every Imp.Module, call/2 returns {:ok, prediction} or
{:error, reason}. With n: 0 the reason is :no_attempts; when
more attempts fail than :fail_count allows it is
{:refine_fail_count_exceeded, reason}; when every attempt failed it is the
last attempt's reason.