modify training scripts to use optimizer