I don’t think it would affect the gradients anyway, which are basically determined by l = citerion(...). Summing them up just makes it convenient since we can only call loss.backward() once.
If I understand correctly, we could in principle do something like this:
losses = []

for i in range(input_line_tensor.size(0)):
    output, hidden = rnn(category_tensor, input_line_tensor[i], hidden)
    l = criterion(output, target_line_tensor[i])
    losses.append(l)

for l in losses:
    l.backward()