The Code of Criminal Procedure, 1973 (CrPc)
338. Procedure where lunatic detained is declared fit to be released.
(1) If such person is detained under the provisions of sub-section (2) of section 330, or section 335, and such Inspector-General or visitors shall certify that, in his or their judgment, he may be released without danger of his doing injury to himself or to any other person, the State Government may thereupon order him to be released, or, to be detained in custody, to be transferred to a public lunatic asylum if he has not already sent to such an asylum; and, in case it orders him to be transferred to an asylum, may appoint a commission consisting of a judicial and two medical officers.
(2) Such Commission shall make a formal inquiry, into the state of mind of such person, take such evidence as is necessary, and shall report to the State Government, which may order his release or detention as it thinks fit