Solved by aRI0U in post #7 
              
              
                I found a way to do this which is about 100x faster and is also better in terms of memory usage. The main idea is to directly extract the indices from the PackedSequence itself instead of padding it. 
Assuming you have a PackedSequence object named packed and containing sequences of respective lengt…