It’s hard to say without knowing the objective, but I would maybe do something like this:
rnn = torch.nn.RNN(16, 16)
x1 = torch.randn((1, 1, 16))    # Example input for one-to-many
seq_output_len = 5              # I want a sequence of five produced

yn = x1
hn = None
outputs = []
for _ in range(seq_output_len):
    yn, hn = rnn(yn, hn)        # Use previous output and hidden state
    outputs.append(yn)

output = torch.cat(outputs)     # 5 x 1 x 16
loss = do_something(output)
loss.backward()


This is a simplistic example which will vary on your use case