KAM Theory Meets Statistical Learning Theory: Hamiltonian Neural Networks with Non-zero Training Loss