Indexing with negative padded tensor

Hello Everyone,

I have a padded tensor with negative values, and I would like to use that tensor to index another tensor. One way of doing is by first selecting the positive values using a mask and then taking the positive values. Is there any function in PyTorch that does in an optimized way? Thanks a lot