Could you remove the inplace operation and check, if this would solve the error?
    def forward(self, z):
        for i in range(self.path_length-1):
            z = z + self.layers[i](z)
            noise = (self.noisefactor * torch.normal(0,1,z.size())).detach()
            z = z + noise
        return z