Before training, or inside the model
Raw data needs feature engineering, and there are two places to do it. Before training, a separate step transforms the data once and stores the result. You can study the whole dataset to choose the transforms. But you have to repeat exactly the same transforms when serving, often in different code. The gap that opens up is training-serving skew, and it's the classic production bug.
Inside the model, the transforms are part of the model code. Training and serving are then the same by construction, and changing a transform doesn't mean rebuilding the stored data. The costs are that the transforms run for every batch and add latency.
Watch one trap on the board. Z-scores need a mean and a standard deviation. Compute them per batch and the same 4-goal match gets a different z-score in every batch. Press Another batch and compare. The fix is to compute the mean and SD once over the whole training set and use them as fixed numbers, in training and when serving.