torch.nn.utils.rnn.invert_permutation torch.nn.utils.rnn.invert_permutation(permutation) Returns the inverse of permutation. This is useful for converting between sorted and unsorted indices in a PackedSequence. Parameters: permutation () – a 1-D tensor of indices to invert