code: def test_welford_dense(n_samples, dim_size):
      w = WelfordCovariance(diagonal=False)
      loc = torch.zeros(dim_size)
      cov = torch.randn(dim_size, dim_size)
      cov = torch.mm(cov, cov.t())
      dist = torch.distributions.MultivariateNormal(
          loc=loc, covariance_matrix=cov
      )
      samples = dist.sample(torch.Size([n_samples]))
      for sample in samples:
          w.update(sample)
  
      with optional(pytest.raises(RuntimeError), n_samples == 1):
          estimates = w.get_covariance(regularize=False).cpu().numpy()
          sample_cov = np.cov(
              samples.cpu().numpy(), bias=False, rowvar=False
          )
          assert_equal(estimates, sample_cov)
  
file_path: pyro/tests/ops/test_welford.py
imports: import numpy
  import pytest
  import torch
  from pyro.ops.welford import WelfordArrowheadCovariance, WelfordCovariance
  from pyro.util import optional
  from tests.common import assert_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_welford_dense(n_samples, dim_size) without return types