Safe Imitation Learning of Nonlinear Model Predictive Control for Flexible Robots