I want to index a tensor like this:

A = [[4,5],[6,7]], index = [[0,2],[2,1]] -(?)-> [[nan, nan, 6], [4, 7 ,5]].

Basically, the element in index is the column in the output array the corresponding element in A belongs to, while the row index is simply stacked based on the number of occurrences of the column number in index.
Can I convert this to numpy, do the transformation, and convert back to a tensor in the middle of my ML pipeline, as numpy has more sophisticated array indexing? Can I just do this using pytorch?