They are computed element-wise (in the batch dim) and then averaged. If your sensor has N elementa, loss is computed pixel-wise for each element in the batch, averaged and then averaged in the batch dim