(1) The defendant may be found guilty but mentally ill if:
(a) The prosecution proves beyond a reasonable doubt that the defendant is guilty of an offense; and (b) The defendant proves by a preponderance of the evidence that he was mentally ill at the time of the offense.
(2) If the defendant waives his right to trial, the court may accept a plea of guilty but mentally ill if it finds that the defendant was mentally ill at the time of the offense.