The Marbeh Torah (160:29) adds: It’s permissible to lend money to a talmud chocham even with a pre-condition that he learns Mishnayos leiluy nishmas the lender once he passes away. The reason being: The borrower is even allowed to praise the lender once he passes away, as there is no longer a debt between the lender and borrower. The debt is now between the borrower and the children of the lender, and the entire prohibition of ribbis devorim is only when the borrower has the lenders money in his hand, in this case, the lender is no longer alive, therefore, it is no longer considered that the borrower has his money in his hand.
The Marbeh Torah further adds: That when the lender passes away, he is no longer considered אחיך – “a brother” and he is exempt from mitzvos, therefore, there is no longer any problem of ribbis.