code: def test_reload(backend, dtype):
      with backend() as backend1:
          run_sampler(backend1, dtype=dtype)
  
          # Test the state
          state = backend1.random_state
          np.random.set_state(state)
  
          # Load the file using a new backend object.
          backend2 = backends.HDFBackend(
              backend1.filename, backend1.name, read_only=True
          )
  
          with pytest.raises(RuntimeError):
              backend2.reset(32, 3)
  
          assert state[0] == backend2.random_state[0]
          assert all(
              np.allclose(a, b)
              for a, b in zip(state[1:], backend2.random_state[1:])
          )
  
          # Check all of the components.
          for k in ["chain", "log_prob", "blobs"]:
              a = backend1.get_value(k)
              b = backend2.get_value(k)
              _custom_allclose(a, b)
  
          last1 = backend1.get_last_sample()
          last2 = backend2.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:]
              )
          )
          _custom_allclose(last1.blobs, last2.blobs)
  
          a = backend1.accepted
          b = backend2.accepted
          assert np.allclose(a, b), "inconsistent accepted"
  
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 9 for calling a global function with example usage: test_reload(backend, dtype) without return types