Efficient Hyperparameter Tuning via Trajectory Invariance Principle