code: def test_sample_examples(
      sample, weights, expected_mean, expected_var
  ):
      emp_dist = Empirical(sample, weights)
      num_samples = 10000
      assert_equal(emp_dist.mean, expected_mean)
      assert_equal(emp_dist.variance, expected_var)
      emp_samples = emp_dist.sample((num_samples,))
      assert_close(emp_samples.mean(0), emp_dist.mean, rtol=1e-2)
      assert_close(emp_samples.var(0), emp_dist.variance, rtol=1e-2)
  
file_path: pyro/tests/distributions/test_empirical.py
imports: import pytest
  import torch
  from pyro.distributions.empirical import Empirical
  from tests.common import assert_close, assert_equal
label_desc: Use image node_id 3 for calling a global function with example usage: test_sample_examples(sample, weights, expected_mean, expected_var) without return types