I have a 3-dimentional pytorch array (rows x Column x K) .Lets name the array as ‘X’. I have a list of tuples , ‘L’ . For every tuple (a,b) in ‘L’, I want to swap the values at X[a,b,a] and X[a,b,b]. Is there a fast pytorch operation for this?

You may use pytorch tensor indexing to both access and set the values of
the desired elements, together with a helper tensor to temporarily store the
values being swapped: