Write early_stop(val, patience) returning (stop_epoch, best_epoch, best_val) — stop after patience consecutive non-improvements, or at the last epoch. Run it with patience 1 and 5 on the noisy curve (note the up-jitter at epoch 2) and print f"patience={p}: stopped at {stop_e}, kept epoch {best_e} (val={best})" for each. This is stage 4: one knob, two very different outcomes.