The Code of Criminal Procedure, 1973 (CrPc)
339. Delivery of lunatic to care or relative or friend.
(1) Whenever any relative friend of any person detained under the provisions of section 330 or section 335 desires that he shall be delivered to his care and custody, the State Government may, upon the application of such relative or friend and on his giving security to the satisfaction of such State Government, that the person delivered shall-
(a) Be properly taken care of and prevented from doing injury to himself or to any other person;
(b) Be produced for the inspection of such officer, and at such times and places, as the State Government may direct.
(c) In the case of a person detained under subsection (2) of section 330, be produced when required before such Magistrate or court, order such person to be delivered to such relative or friend.
(2) If the person so delivered is accused of any offence, the trial of which has been postponed by reason of his being of unsound mind and incapable of making his defence, and the inspecting officer referred to in clause (b) of sub-section (1) certifies at any time to the Magistrate or court that such person is capable of making his defence, such Magistrate or court shall call upon the relative or friend to whom such accused was delivered to produce him before the Magistrate or court, and, upon such production the Magistrate of court shall proceed in accordance with the provisions of section 332, and certificate of the inspecting officer shall be receivable as evidence.