Ok, then it makes sense.
I would suggest first to initialize your hidden with the good shape (1, hidden_size) so you can directly update them:
hiddenStates = []
hiddenStates.append(input)
# init hidden:
for idxLayer in range(self.n_layers):
    hiddenStates.append(Variable(torch.zeros(1,hidden_size))
# then hiddenStates is a list of Variables of size n_layer+1
for idxLayer in range(self.n_layers):
    currentCell = self.grucells[idxLayer+1]
    hiddenStates[idxLayer+1] = currentCell(hiddenStates[idxLayer], hiddenStates[idxLayer+1])
z = 0
for hidden in hiddenStates[1:]:
    z += hidden.sum()
z.backward()

That way, you don’t do any inplace operation