Whenever a person has entered upon a term of imprisonment in a penal or correctional institution, and whenever during the continuance of the term of imprisonment there is a detainer lodged against the prisoner by a law enforcement or prosecutorial agency of the state or its subdivisions, the Department of Corrections may do either of the following:
(a)
Release the inmate to the agency lodging the detainer, within five days, or five court days if the law enforcement agency lodging the detainer is more than 400 miles from the county in which the institution is located, prior to the scheduled release date provided the inmate is kept in custody until the scheduled release date.
(b)
Retain the inmate in custody up to five days, or five court days if the law enforcement agency lodging the detainer is more than 400 miles from the county in which the institution is located, after the scheduled release date to facilitate pickup by the agency lodging the detainer.
If a person has been retained in custody under this subdivision in response to the issuance of a warrant of arrest charging a particular offense and the defendant is released from custody following the retention period without pickup by the agency lodging the detainer, a subsequent court order shall be issued before the arrest of that person for the same offense which was charged in the prior warrant.
As used in this section “detainer” means a warrant of arrest.