Neural networks with not-fixed dimension for input and output
If youre searching for neural network architecture that have varying number of inputs and outputs, Recurrent Neural Networks, LSTM's .. etc are examples. They are used in Natural Language Processing where the main goal is to examine patterns in sentences.  But I highly doubt that they will work for your use case since no information about it is provided.
Another way would be to create multiple neural networks with a different input/ output sizes, such that the input/output sizes are averages of the groups of similar input/output sizes.