# Why do code implementations average the loss over a batch instead of finding the expected sample of that batch (using sampling probabilities)

Usually, our training objective over a batch is written in terms of the expected value of a sample in that batch such as

$$objective = E_{x \sim data} * log(P(x))$$

But in the code implementations, these objectives are averaged over the batch, even if it very obvious that they might not have been sampled uniformly.

Is this just for simplification purposes or is there backing to both of them being equivalent in the training sense?