Connecting a backbone to a head

Hello,

how would I automate the connection between a backbone and a head?
I’m interested into developing some code for replacing the backbone of any model, if its backbone is known by the code.

So let’s say I have a model using a resnet backbone, I detected the backbone and the head, and I would like to replace resnet by mobilenet.
The problem I see is mainly the mismatch between dimensions, I guess I need a layer in between to make the connection.