On this daf, we find astonishing advice: “If someone’s evil inclination overpowers him, let him go someplace he is not known, don black garments and do as his heart desires.” Could this possibly mean that he is permitted to act on his impulse, chas veshalom?
Rashi brings from Rav Hai Gaon that by following this advice, his heart will be broken and he will not sin. Tosafos quotes Rabbeinu Chananel, who explains that this is not like it literally appears. Rather, if he follows this advice, his heart will be moved and he will refrain from sin. In Kiddushin 40, Tosafos adds the reasoning for this. He points out that first this person will have to travel and stay at various establishments on his way. There, he puts on black garments, which are meant to weary him and he will avoid the sin instead.
The Maharsham brings a very satisfying explanation of his own: “The Rambam famously rules that if a man refuses to divorce his wife when he is required to do so, he can be struck until he declares that he is willing to divorce. Even though a coerced divorce is not kosher, this not considered coerced, since his heart desires to do what is right. That’s why our sages here didn’t conclude that he should do the sin. Rather, they say he should do what his heart desires. This means that he should veer from his original negative intentions by overcoming his base desire.”
The Toldos Yaakov Yosef explains this in a different context: “This refers to a person who wants to do teshuvah but is afraid that people will laugh at him. He should go to where no one knows him, put on black to arouse his heart, and repent as his heart desires” (Migedolei HaTorah V’hachassidus; Iggeres Hakodesh; Toldos Yaakov Yosef, Parshas Tzav).