EmbeddingBag looks up a variable number of ids per example and pools them, without building a padded tensor.
The input is a flat list of ids plus offsets marking where each bag starts (PyTorch's format). Implement embedding_bag(table, ids, offsets, mode="mean") with mode in "sum", "mean", "max". An empty bag returns a row of zeros.