Optimal Guarantees for Algorithmic Reproducibility and Gradient Complexity in Convex Optimization