I'm of the opinion if the crime is heinous enough, even if it can be proved mental illness/episode was a contributing factor, the perpetrator should still be locked up for life due to the crime itself.
IMHO, the sentence should be made up of four elements:
- deterrent
- punishment
- protection of society and the law-abiding
- rehabilitation
(in no particular order).
The "punishment" aspect will probably be judged as either essential, or as "below decent societal norms", depending on your particular point-of-view.
So that leaves "deterrent", "the good of others", and "rehab."
"Deterrent" has been shown, time and again, to be of limited value. Might this be associated with some sort of mental issue?
"The good of others"; for me, this is the majority of the purpose of sentencing.
Keep the scrotes and miscreants away, for the betterment of the rest of our lives.
"Rehab."; a lot to unpack there. Perhaps a whole other thread's worth.