Thanks, it works but now I got this error:
<ipython-input-112-4098c099a02e> in sample(self, n)
     28         """
     29         sample = torch.randn(n, K).to(device)
---> 30         out = cvae.decode(sample, cond_dim)
     31 
     32         return out.cpu().detach().numpy()

<ipython-input-112-4098c099a02e> in decode(self, z, c)
     34 
     35     def decode(self, z, c):
---> 36         concat_input = torch.cat([z, c], 1)
     37         return self.fc5(F.selu(self.fc4(F.selu(self.fc3(concat_input)))))
     38 

TypeError: expected Tensor as element 1 in argument 0, but got int

Is it because of torch.cat?