ht to competence so that you can stand trial, or be returned to regular jail/prison if you have been transferred to a mental treatment ward after you have already started serving your sentence.
As being held in a mental treatment facility is technically not a "punishment" an inmate or prisoner can be put in one as long as is deemed necessary and their trial date is suspended until competence is reached, and it does not count as "time served".