If the prisoner is not entitled to discharge and is not bailed the court or judge shall remand the prisoner to the custody from which taken, if the person who had custody is legally entitled to custody; if not so entitled, the prisoner shall be committed to his or her legal custodian.
Wis. Stat. § 782.24