You can just create one instance of inner model and pass all inputs through it. But in your example there’s no actual reason to have one. You can pass different inputs through the base model directly. But it really depends on what you want to achieve. If you want to train multiple (sub)models separately, each based on it’s own inputs, then your architecture is just fine. Otherwise it can damage training process, for example for triplet loss if you train one instance based on positive examples only and one on negative, both models may not converge.
So, instead of m1…mn you can create one instance m and pass all examples through it. Not sure about ids, just tested it here and there are different ids per instance.