Loss for a batch

Is there are any technique (or anywhere I can read about it) to train the model with the loss function, which is calculated for a batch of observations, instead of each specific observation?

smth like rmse(y[n:n+7], y_hat[n:n+7]) instead of rmse(y, y_hat)

I mean, if I wanted to predict the forecast for each day for a week, but my target “loss function” is the precision of forecasting for a seven days batch. Each day can variate more or less, but the sum of 7 days should be as much precise as it can be.

The output of MSE is a scalar so it’s already doing what you ask.