(a) A court may punish a defendant who is convicted of a state jail felony by imposing the confinement permissible as punishment for a Class A misdemeanor if, after considering the gravity and circumstances of the felony committed and the history, character, and rehabilitative needs of the defendant, the court finds that such punishment would best serve the ends of justice.
(b) At the request of the prosecuting attorney, the court may authorize the prosecuting attorney to prosecute a state jail felony as a Class A misdemeanor.