I think its common to calculate it like this:
batch_loss += loss.item() * batch_size

Then at the end of the epoch we divide the number with the number of steps.
We multiply it with the batch size since loss.item() returns the average loss for each sample within the batch, so to get per sample overall we have to correct for that.