How to realize batch training with tree-structured model

I am exploring a model similar to Recursive NN. The difference is that the number of a node’s children can be more than 2 in my model. I have read the tutorial “Recursive Neural Networks with PyTorch”, however, I am still confused about how to realize my model in a batch manner. Can someone give any suggestions or existing examples? Thanks!