When two or more defendants are included in the same accusatory pleading, the court may, at any time before the defendants have gone into their defense, on the application of the prosecuting attorney, direct any defendant to be discharged, that he may be a witness for the people.