Your self.mean, self.mean_sq are also backed by dynamically graph. When you do forward on different x, the self.mean, self.mean_sq are the same. Then when you backward from the output of forward, it will backprop through the graph to comput self.mean, self.mean_sq multiple times.
I don’t know what the intended behavior is. Do you want to backprop through those variables or not? AFAIK, in vanilla BN, it is important to backprop through batch statistics so that nothing is hidden from the optimizers. But here, it seems that you are using the same statistics for different input batch x.