Thanks Guanheng, unfortunately my sequences are not fixed length so it seems I cannot use the EmbeddingBag approach. Do you have some other ideas?

Edit 1: This is there error I’m seeing that lead me to this assumption:
“ValueError: if input is 2D, then offsets has to be None, as input is treated is a mini-batch of fixed length sequences”
Edit 2: I was incorrect, you can use EmbeddingBag with variable length sequences. One needs to first flatten the sequences (to avoid the above 2D error) and provide offsets to the positions of the tensors