That is called the Magnet Train. You have to beat the pokemon league, then take a boat in Olivine City to a town in Kanto (forgot the name of the town/city), Then do some things in Kanto, and you should then be able to take the Magnet Train from Kanto to Johto, and from Johto to Kanto. I believe you have to get something that was stolen from the powerplant in Kanto, then return it to the powerplant, and then go to the Copycat's house in Saffron City and talk to Copycat, then go to the pokemon fanclub and go in and talk to someone there (can't remember who), and they will give you a stuffed animal/plushie for Copycat. Take it to Copycat, and she should give you a Magnet Train pass.