parallize training code