It is not just where the piracy takes place, but where you catch them. The piracy may be on the high seas, but once they are within ‘12 miles of the beach’ international forces are not supposed to touch them.
It is rumored that the Russians and the Chinese practice your favorite scenario.
For the rest, the law used to be trial at sea followed by execution. But with modern communications the captain of a vessel longer has the power of a feudal lord and the civil rights people have written laws requiring a civilian court trial. Which means either the closest nation, the nation in which the pirated vessel is registered, or the nation of the warship that apprehended the pirates. Unfortunately the closest nation is in Africa, and cannot afford the number of trials and incarcerations. Also, the EU refuses to send any pirates to nations where they might be subject to the death penalty. Most of the nations to which the ships are registered don’t want the expenses either. So that leaves the nation to which the warship belongs.
Other problems include the cost of incarceration after conviction, and what to do with them after they have served it. Especially in the EU the various human rights treaties and the EU constitution are being interpreted in such a way that they may become economic refugees even before the trial starts. This is why catch-and-release is the norm for EU vessels.