BatchNorm layers shouldn’t return NaN values, if the input is well defined.
You could add assert statements to the input and output of this batchnorm layer and check if all values are finite via torch.isfinite(tensor).