Solved by yash1994 in post #2 
              
              
                simple. You just pass shared layers as argument to class initialization. 
class RNN(nn.Module):
    def __init__(self, input_size, hidden_size, output_size, x2h, h2h):
        super(RNN, self).__init__()

        self.x2h = x2h
        self.h2h = h2h
        self.hidden_size = hidden_size
        se…