Sharing weights between two models

Suppose, I have two models A and B. I have two different classes of these two models. Now, I want to share weights between these two classes. How can I do that?

The most elegant way is probably using the functional forms and manually passing in the parameters: http://pytorch.org/docs/0.2.0/nn.html#torch-nn-functional