Well the batchnorm layer does not really make sense if all inputs are the same. Because beyond the fact that you get nan gradients, all the values that you forward are 0s. Is that expected in your case?
Also if all these values are 0s, that mean that all the gradients flowing back will be 0s as well. So you won’t be able to learn anything runs before the batchnorm.
If that’s what you want, you can simply set everything before the batchnorm not to require gradients.