The same for ships, in which case engines with generators provide all the electricity needed for the electric motors, and even smaller batteries.
I am not sure why semi-trucks don't use a similar system to train locomotives. Small diesel engine turning a generator that powers electric motors on all the wheels except the steers. You could even add motors on the trailer wheels.