A measure theoretical approach to the mean-field maximum principle for training NeurODEs