code: def test_errors(backend, nwalkers=32, ndim=3, nsteps=5, seed=1234):
      # Set up the random number generator.
      np.random.seed(seed)
  
      with backend() as be:
          # Initialize the ensemble, proposal, and sampler.
          coords = np.random.randn(nwalkers, ndim)
          sampler = EnsembleSampler(
              nwalkers, ndim, normal_log_prob, backend=be
          )
  
          # Test for not running.
          with pytest.raises(AttributeError):
              sampler.get_chain()
          with pytest.raises(AttributeError):
              sampler.get_log_prob()
  
          # What about not storing the chain.
          sampler.run_mcmc(coords, nsteps, store=False)
          with pytest.raises(AttributeError):
              sampler.get_chain()
  
          # Now what about if we try to continue using the sampler with an
          # ensemble of a different shape.
          sampler.run_mcmc(coords, nsteps, store=False)
  
          coords2 = np.random.randn(nwalkers, ndim + 1)
          with pytest.raises(ValueError):
              list(sampler.run_mcmc(coords2, nsteps))
  
          # Ensure that a warning is logged if the inital coords don't allow
          # the chain to explore all of parameter space, and that one is not
          # if we explicitly disable it, or the initial coords can.
          with pytest.raises(ValueError):
              sampler.run_mcmc(np.ones((nwalkers, ndim)), nsteps)
          sampler.run_mcmc(
              np.ones((nwalkers, ndim)),
              nsteps,
              skip_initial_state_check=True,
          )
          sampler.run_mcmc(np.random.randn(nwalkers, ndim), nsteps)
  
imports: import pickle
  from itertools import islice, product
  import numpy
  import pytest
  from emcee import EnsembleSampler, backends, moves, walkers_independent
label_desc: Use image node_id 3 for calling a global function with example usage: test_errors(backend, nwalkers, ndim, nsteps, seed) without return types