It’s a bit involved to do it currently with pytorch.
A proof of concept that was working before some pytorch changes can be seen in https://gist.github.com/fmassa/f8158d1dfd25a8047c2c668a44ff57f4 198
(but you first need to perform the 2 slicings before using the advanced indexing)