How is electricity generated in trains?

Since the end of the 19th century, the history of electricity and the history…