code: def test_backend(backend, dtype, blobs):
      # Run a sampler with the default backend.
      sampler1 = run_sampler(
          backends.Backend(), dtype=dtype, blobs=blobs
      )
  
      with backend() as be:
          sampler2 = run_sampler(be, dtype=dtype, blobs=blobs)
  
          values = ["chain", "log_prob"]
          if blobs:
              values += ["blobs"]
          else:
              assert sampler1.get_blobs() is None
              assert sampler2.get_blobs() is None
  
          # Check all of the components.
          for k in values:
              a = getattr(sampler1, "get_" + k)()
              b = getattr(sampler2, "get_" + k)()
              _custom_allclose(a, b)
  
          last1 = sampler1.get_last_sample()
          last2 = sampler2.get_last_sample()
          assert np.allclose(last1.coords, last2.coords)
          assert np.allclose(last1.log_prob, last2.log_prob)
          assert all(
              np.allclose(l1, l2)
              for l1, l2 in zip(
                  last1.random_state[1:], last2.random_state[1:]
              )
          )
          if blobs:
              _custom_allclose(last1.blobs, last2.blobs)
          else:
              assert last1.blobs is None and last2.blobs is None
  
          a = sampler1.acceptance_fraction
          b = sampler2.acceptance_fraction
          assert np.allclose(a, b), "inconsistent acceptance fraction"
  
file_path: emcee/src/emcee/tests/unit/test_backends.py
imports: import os
  from itertools import product
  from os.path import join
  import numpy
  import pytest
  from emcee import EnsembleSampler, State, backends
  from emcee.backends.hdf import does_hdf5_support_longdouble
label_desc: Use image node_id 8 for calling a global function with example usage: test_backend(backend, dtype, blobs) without return types