Section 369(2) in Bharatiya Nagarik Suraksha Sanhita, 2023
(2)If the case is one in which, in the opinion of the Magistrate or Court, as the case may be, bail cannot be granted or if an appropriate undertaking is not given, he or it shall order the accused to be kept in such a place where regular psychiatric treatment can be provided, and shall report the action taken to the State Government:Provided that no order for the detention of the accused in a public mental health establishment shall be made otherwise than in accordance with such rules as the State Government may have made under the Mental Healthcare Act, 2017.