I have a encoder-decoder architecture. I want to do two things:

I wanna stack the same network three times
and share the weights of some layers (the layers from green areas), and not all layers (not the pink ones)
Some thing Iike this image:



I am new to pytorch and I am not shore how to do it.
I appreciate your help for any reference or sudo code.