A learning-based multiscale method and its application to inelastic impact problems