def METHOD_NAME(hi, ham, ma, n_chains):
    w = ma.init(jax.random.PRNGKey(WEIGHT_SEED * n_chains), jnp.zeros((1, hi.size)))
    sampler = nk.sampler.MetropolisLocal(hi, n_chains=n_chains)
    n_samples = 16000
    num_samples_per_chain = n_samples // n_chains
    # Discard a few samples
    _, state = sampler.sample(ma, w, chain_length=1000)
    samples, state = sampler.sample(
        ma, w, chain_length=num_samples_per_chain, state=state
    )
    assert samples.shape == (n_chains, num_samples_per_chain, hi.size)
    eloc = local_values(ma.apply, w, ham, samples)
    assert eloc.shape == (n_chains, num_samples_per_chain)
    stats = statistics(eloc.T)
    assert stats.mean == pytest.approx(np.mean(eloc))
    if n_chains > 1:
        # variance == average sample variance over chains
        assert stats.variance == pytest.approx(np.var(eloc))