Three men in the western Indian city of Mumbai will clean a railway station for three days as punishment for doing the viral Kiki challenge on a train.

Their "sentence" was decided by a magistrate after police arrested the men and produced them before a court.

Their video portrays how people in different Indian states would perform the Kiki challenge.

Also called the In My Feelings challenge, it involves people dancing to a song by Canadian artist Drake.

Many videos posted online, however, show people getting out of a moving car and dancing as the driver films. The trend has sparked warnings from authorities in several countries, including India.

The video on the Indian train, uploaded to YouTube under the name Funcho Entertainment, has more than two million views.

In the video, one of the men steps off the train and starts dancing to the song while his friend films it on a mobile phone. When the train starts to move, he runs alongside it while dancing. The video also shows his friend partially hanging out of the door of a moving train and attempting a dance move.

"We found the video on YouTube and found CCTV footage of them participating in the challenge at the Virar station," senior railway official Anup Shukla told the BBC.

The magistrate told the men they had done "something wrong", adding: "Now you will create public awareness for the next three days that this was wrong and it endangers you and others."

But a comment left by the administrators of Funcho Entertainment reassured their fans that the Kiki dancers were none the worse for their punishment.

"Everything is fine guys. We're all good. You'll get all the updates of what exactly happened and everything in one of our upcoming video. Till then stay tuned," it reads. 

One of the men is a small-time television actor, Indian media said.

The craze began when internet comedian Shiggy posted a video to Instagram of himself dancing to the song.

It is unclear how his video morphed into people jumping out of moving cars and dancing.

Some in India have posted footage of distinctive takes on the viral challenge.