From my understanding, a loss function first computes the loss for each sample, then it either reduces the list of losses and outputs a scalar or outputs the list itself.