How to train a neural network on a list of tensors with different shapes

Actually my code is to implement a graph neural network and the examples are graphs including different number of nodes. There are node2edge and edge2node operations in the forward process, which need matrix which is specific for each graph.