law: Code of Criminal Procedure Act, 1973
  
  330.Release of lunatic pending investigation or trial.-
  (1) Whenever a person is found, under section
  
  328 or section 329, to be of unsound mind and incapable of making his defense,
  
  the Magistrate or Court, as the case may be, whether the case is one in which
  
  bail may be taken or not, may release him on sufficient security being given
  
  that he shall be properly taken care of and shall be prevented from doing
  
  injury to himself or to any other person, and for his appearance when required
  
  before the Magistrate or Court or such officer as the Magistrate or Court
  
  appoints in this behalf.
  (2) If the case is one in which, in the opinion of the Magistrate or Court,
  
  bail should not be taken, or if sufficient security is not given, the
  
  Magistrate for Court, as the case may be, shall order the accused to be
  
  detained in safe custody in such place and manner as he or it may think fit,
  
  and shall report the action taken to the State Government:
  
  Provided that no order for the detention of the accused in a lunatic
  
  asylum shall be made otherwise than in accordance with such rules as the State
  
  Government may have made under the Indian Lunacy Act, 1912 (4 of 1912).