<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _ilsr(fun, params, max_iter, tol):
 """Iteratively refine LSR estimates until convergence. Raises ------ RuntimeError If the algorithm does not converge after ``max_iter`` iterations. """

    converged = NormOfDifferenceTest(tol, order=1)
    for _ in range(max_iter):
        params = fun(initial_params=params)
        if converged(params):
            return params
    raise RuntimeError("Did not converge after {} iterations".format(max_iter))