Jami` at-Tirmidhi Book 17, Hadith 2
that the Messenger of Allah (ﷺ): "Avert the legal penalties from the Muslims as much as possible, if he has a way out then leave him to his way, for if the Imam makes a mistake in forgiving it would be better than making mistake in punishment."
That the Messenger of Allah (ﷺ) said: "The pen has been lifted from three; for the sleeping person until he awakens, for the boy until he becomes a young man and for the mentally insane until he regains sanity."
(Another chain) which is similar to the narration of Muhammad bin Rabi'ah (a narrator in no.1424) but he did not narrate it in Marfu' form.