Your pseudocode is already basically correct - here’s a simplified case:
input = some_input
hidden = model.init_hidden()

for i in range(seq_len):
    input, hidden = model(input, hidden)

# Do something with final states...

Here’s a more thorough example modified from a tutorial 68
for i in range(target_length):
    output, hidden = decoder(input, hidden)

    loss += criterion(output, target[i])

    # Create new input from max value
    top_v, top_i = output.data.topk(1)
    top_i = top_i[0][0]
    input = Variable(torch.LongTensor([[top_i]]))

In this case the input is an embedding and the output is from log_softmax, so to get the next input you have to create a new input from the maximum value.