I don’t know where these scatter_ methods are defined, but since you are getting invalid values using scatter_std I assume that this particular method might return NaN (outputs or gradients) for edge cases, e.g. when the values are constant.