code: def test_incremental_variance_ddof():
      # Test that degrees of freedom parameter for calculations are correct.
      rng = np.random.RandomState(1999)
      X = rng.randn(50, 10)
      n_samples, n_features = X.shape
      for batch_size in [11, 20, 37]:
          steps = np.arange(0, X.shape[0], batch_size)
          if steps[-1] != X.shape[0]:
              steps = np.hstack([steps, n_samples])
  
          for i, j in zip(steps[:-1], steps[1:]):
              batch = X[i:j, :]
              if i == 0:
                  incremental_means = batch.mean(axis=0)
                  incremental_variances = batch.var(axis=0)
                  # Assign this twice so that the test logic is consistent
                  incremental_count = batch.shape[0]
                  sample_count = np.full(
                      batch.shape[1], batch.shape[0], dtype=np.int32
                  )
              else:
                  result = _incremental_mean_and_var(
                      batch,
                      incremental_means,
                      incremental_variances,
                      sample_count,
                  )
                  (
                      incremental_means,
                      incremental_variances,
                      incremental_count,
                  ) = result
                  sample_count += batch.shape[0]
  
              calculated_means = np.mean(X[:j], axis=0)
              calculated_variances = np.var(X[:j], axis=0)
              assert_almost_equal(
                  incremental_means, calculated_means, 6
              )
              assert_almost_equal(
                  incremental_variances, calculated_variances, 6
              )
              assert_array_equal(incremental_count, sample_count)
  
imports: import numpy
  import pytest
  from scipy import linalg, sparse
  from scipy.linalg import eigh
  from scipy.sparse.linalg import eigsh
  from scipy.special import expit
  from sklearn.datasets import make_low_rank_matrix, make_sparse_spd_matrix
  from sklearn.utils import gen_batches
  from sklearn.utils._arpack import _init_arpack_v0
  from sklearn.utils._testing import assert_allclose, assert_allclose_dense_sparse, assert_almost_equal, assert_array_almost_equal, assert_array_equal, skip_if_32bit
  from sklearn.utils.extmath import _deterministic_vector_sign_flip, _incremental_mean_and_var, _randomized_eigsh, _safe_accumulator_op, cartesian, density, log_logistic, randomized_svd, row_norms, safe_sparse_dot, softmax, stable_cumsum, svd_flip, weighted_mode
  from sklearn.utils.fixes import COO_CONTAINERS, CSC_CONTAINERS, CSR_CONTAINERS, DOK_CONTAINERS, LIL_CONTAINERS, _mode
label_desc: Use image node_id 29 for calling a global function with example usage: test_incremental_variance_ddof() without return types