Efficient implementation of multi-row slicing

Dear all,

Here is an example of what I’m trying to implement :
I have at my disposal a 1-d tensor of start indexes S, a 1-d tensor of end indexes E, 2 2-d tensors M and R.
I would like to modify M as follows :

for i in range(M.size(0)):
         M[i, S[i]: E[i] + 1] = R[i, S[i]: E[i] + 1]

Is there a way to do this without a loop ? (N.B : The lengths E[i] - S[i] are different in general)

Thank you very much