@ptrblck If I understand correctly, your suggested approach sums the losses over all timesteps of the sequence. I made an example with dummy tensor data to demonstrate this behavior
import torch
import torch.nn as nn

batch_size = 5
seq_len = 9
num_classes = 36

scores = torch.rand((batch_size, num_classes, seq_len))  # Model output
targets = torch.randint(0, num_classes, (batch_size, seq_len))
criterion = nn.CrossEntropyLoss(reduction='sum')

auto_sum = criterion(scores, targets)
manual_sum = 0
for timestep in range(scores.size(2)):
  score_t = scores[:, :, timestep]
  target_t = targets[:, timestep]
  manual_sum += criterion(score_t, target_t)
print(f'Manual {manual_sum:.6f} vs. auto {auto_sum:.6f}')

Would the auto_sum method be your preferred approach for loss calculation when training an encoder-decoder architecture for neural machine translation? Do you know of a preference among practitioners for summing across timesteps vs. averaging?