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 4.
def backprop(self, y, zs):
    zbar = torch.ones_like(y)
    for l in range(len(self.net) - 1, 0, -1):
        linear_layer = self.net[l] 
        zbar =  torch.matmul(zbar, linear_layer.linear.weight) * linear_layer.deriv_activation_function(zs[l-1])
        zbar.detach_() # eq. zbar = zbar.detach()
    linear_layer = self.net[0]
    zbar = torch.matmul(zbar, linear_layer.linear.weight)
    zbar.detach_() # eq. zbar = zbar.detach()
    xbar = zbar
    return xbar