When you load a model,  pytorch match keys by name. It means  your weights have to match model names, otherwise this msg will appear. This means in your weights there exists keys which does not exist in the model and vice versa.
Another option could be rename model layers but that is more difficult.
Appear of the names the amount of parameters sizes etcetera have to match too.
The problem is not about the function but the key names of your weights.