India has agreed to buy a high-speed bullet train from Japan, in an attempt to transform its creaking rail system.