Optimal Learning for Multi-pass Stochastic Gradient Methods