def _std_var_helper(self, statistic, statistic_name, statistic_ndims,<EOL>df_factor_fn):
df = tf.reshape(<EOL>self.df,<EOL>tf.concat([<EOL>tf.shape(input=self.df),<EOL>tf.ones([statistic_ndims], dtype=tf.int32)<EOL>], -<NUM_LIT:1>))<EOL>df = _broadcast_to_shape(df, tf.shape(input=statistic))<EOL>denom = tf.where(df > <NUM_LIT>, df - <NUM_LIT>, tf.ones_like(df))<EOL>statistic = statistic * df_factor_fn(df / denom)<EOL>inf = dtype_util.as_numpy_dtype(self.dtype)(np.inf)<EOL>result_where_defined = tf.where(<EOL>df > <NUM_LIT>, statistic, tf.fill(tf.shape(input=statistic), inf, name="<STR_LIT>"))<EOL>if self.allow_nan_stats:<EOL><INDENT>nan = dtype_util.as_numpy_dtype(self.dtype)(np.nan)<EOL>return tf.where(df > <NUM_LIT:1.>, result_where_defined,<EOL>tf.fill(tf.shape(input=statistic), nan, name="<STR_LIT>"))<EOL><DEDENT>else:<EOL><INDENT>with tf.control_dependencies([<EOL>assert_util.assert_less(<EOL>tf.cast(<NUM_LIT:1.>, self.dtype),<EOL>df,<EOL>message=statistic_name +<EOL>"<STR_LIT>"),<EOL>]):<EOL><INDENT>return tf.identity(result_where_defined)<EOL><DEDENT><DEDENT>
Helper to compute stddev, covariance and variance.