Thanks, this will make it easy to explain the problem with this code.
I ran your code with a random dataset of

size = (no_samples=100,116)

So in encoder function you first do.
h = self.relu(self.fc1(x))
print(h.size())
#torch.Size([100, 512]) See your fc1 one layer for this output

then
h1 = torch.cat((h, y), dim = 1)
print(h1.size())
#torch.Size([100, 513]) Output because we concat dim (500+1)

then



 Mi_Rak:

`self.hidden = nn.Linear(512,517)


Now considering this.
self.hidden = nn.Linear(512,517) #  will take 512 as input dim

But In forward our output dim is 513 after torch.cat .



 Mi_Rak:

h1 = th.cat((h, y), dim = 1)


So you need to change your self.hidden input channel to 513. Moving forward in your function



 Mi_Rak:

h2 = self.relu(self.hidden(h1))


This will output



 Mi_Rak:

self.hidden = nn.Linear(512,517)  output dim = 517 





 Mi_Rak:

h3 = self.hidden(h2)


Now here is the actual problem, you use the same self.hidden which receives 512 input dim and pass it 517 dim matrix, which cause another size mismatch error.
My advice create thoroughly check the size of our output tensor and create a few more hidden layer which can accept that output tensor.