Did you check what is the type of hidden_init before executing the following line in encoder?
output, hidden_state = self.gru(inputs, hidden_init)
I can see you have converted the inputs to cuda tensor, so only thing that can cause the problem might be related to hidden_init (I guess).