I’m very new to PyTorch but from the documentation I see that when initializing nn.GRU takes (input_size, hidden_size, num_layers).
And regarding the inputs the dimensions seem to correspond to: (batch_size, seq_len, input_size)
Adapting a bit from the examples:
batch_size = 5
input_size = 10
num_layers = 2
hidden_size = 20
seq_len = 3
rnn = nn.GRU(input_size, hidden_size, num_layers)
inp = Variable(torch.randn(batch_size, seq_len, input_size))
h0 = Variable(torch.randn(num_layers, seq_len, hidden_size))
output, hn = rnn(inp, h0)

So the second dimension is the sequence length. This is the behaviour you can see in almost all recurrent modules / layers of every DL library.