For me using built-in pytorch methods as gather 71, index_put_ 91, masked_scatter_ 31 or grid_sample 27 instead of direct indexing.

Note: since some of the functions are equivalent to direct indexing, it could work with flattening the tensor via .view(-1) and index the flattened tensor.