def METHOD_NAME(
    check_lrs: Union[List[float], Tuple[float, ...]],
    steps_per_measurement: int,
    optim: Optimizer,
    analysis: LRLossSensitivityAnalysis,
    loss_key: str,
) -> Tuple[Callable, Callable]:
    measurement_steps = 0
    check_index = -1
    lr_results = None
    def complete_lr():
        nonlocal measurement_steps
        nonlocal check_index
        nonlocal lr_results
        if measurement_steps > 0 and check_index >= 0 and check_index < len(check_lrs):
            lr_res = [res.item() for res in lr_results.result_list_tensor(loss_key)]
            analysis.add_result(check_lrs[check_index], lr_res)
        measurement_steps = 0
        check_index += 1
        lr_results = ModuleRunResults()
        if check_index < len(check_lrs):
            set_optim_learning_rate(optim, check_lrs[check_index])
    complete_lr()  # initial to set the lr
    def batch_end(
        epoch: int,
        step: int,
        batch_size: int,
        data: Any,
        pred: Any,
        losses: Any,
    ):
        nonlocal measurement_steps
        measurement_steps += 1
        if measurement_steps >= steps_per_measurement:
            complete_lr()
        lr_results.append(losses, batch_size)
    def completed():
        complete_lr()  # make sure we didn't miss any
    return batch_end, completed