Pytorch way to write following nested loop

I want to change value of a tensor matrix (mat1) as per the value of tensors in pairs and mat2. I am doing it by running a nested loop as below. Is there any way to write this without using a loop like using gather or any other faster inbuilt commands?
size of mat1 = (bs, seq_len)
size of pairs = (bs, x, 2)
size of mat2= (bs,x, y)

for i in range(mat1.size(0)):
        for j in range(pairs[i].size(0)):
            s,e= pairs[i][j][0], pairs[i][j][1]
            mat1[i][s:e+1] = mat2[i][j][0:e-s+1]

@ptrblck Hi, any help would be appreciated.