Yeah, well, you linked pack_padded_sequence before.
There it is the same, except that the lengths (which is an input to pack_padded_sequence) are not given as a parameter but are implicit in [len(s) for s in sequences] the sum of lengths is then the sum of the lengths parameter (sum(lengths)) or sum([len(s) for s in sequences]).
Best regards
Thomas