I think it’s just wrong input number of fc-layer and usage of cat() fucntion
import torch
hidden_dim = 10

x = torch.randn(hidden_dim, 1).cuda()
print(x.size())
y = torch.cat((x, x), 1)
print(y.size())
y = torch.cat((x, x), 0)
print(y.size())

result is below
torch.Size([10, 1]) <-- hidden_dim x 1
torch.Size([10, 2])
torch.Size([20, 1])  <-- 2 * hidden_dim x 1
so, fixed code is
self.hidden2hidden = nn.Linear(2 * self.hidden_dim, self.hidden_dim)
...
node.calculate_result = self.hidden2hidden(torch.cat((node.children[0].calculate_result, node.children[1].calculate_result), 0))