1. You can either store your states at each step in a FIFO queue, and compute the mean and std on the batch, or compute it online with a formula like new_average = old_average * (n-1)/n + new_value /n (and a similar formula for the variance).
2. You should multiply after the clamp.
2. You should multiply after the clamp.