Solved by pascal_notsawo in post #3 
              
              
                You were right, I changed forward like this: 
def forward(self, x):
    zs = []
    for linear_layer in self.net :
        x, z = linear_layer(x)
        zs.append(z)
    y = x
    return y, zs 

And to correct the problem I just made zbar.detach_() as shown here. 
def backprop(self, y, zs):
    zba…