Understood.
But given a sequence length for the same,  would nn.RNN() calculate loss per sequence. or the loss would be over the batch.
for example. if I have 5 sequences, for batches of size 10 with input features 20 and output features 20 (after a fully connected layer).
for an input tensor of size (5, 10, 20) would both the below approaches mean he same loss ? :

if i looped over first dim 5 times, I get an o/p of size (1,10,20)

calculated a cross_entropy for 10 batches of sequence length one and did loss.backward() in each loop step - ie 5 times per iteration

or

I send the entire sequence at a single pass, I get an o/p of size(5,10,20)

calculate the loss over all 5*10 flattened out tokens  and I do a loss.backward() in each iteration only once ?