Optimal way to implement bag-of-words in a tabular model

Has anyone been able to implemented bag of words using fastai?
I know that bag-of-words may not be the best way to represent information, but I would like to experiment with them in a tabular model where I have items that, some items could belong to multiple categories (10 or 15 categories for one item) and some others only a to a few (2 or 3 categories). So instead of having a fixed number of columns like a one hot encoding, I want to average all the embeddings from an item’s categories and use that new embedding for the network. Any ideas on how to implement this in a way that we could take advantage of all the benefits from fastai?