How to share weights between two models

I want to share some weights between two models using pytorch.

In this code, he make modules(‘G_block_share/D_block_share’) as global variable to share weights, and then use thos modules in two different model classes(‘Generator A&B or Discriminator A&B’)

This code is right way to share weights between two models?