code: def get_seeder_and_restorer(
      seed: Hashable = 0,
  ) -> Tuple[Callable[[], None], Callable[[], None]]:
      """Return a pair of functions which respectively seed all and restore
      the state of all registered PRNGs.
  
      This is used by the core engine via `deterministic_PRNG`, and by users
      via `register_random`.  We support registration of additional random.Random
      instances (or other objects with seed, getstate, and setstate methods)
      to force determinism on simulation or scheduling frameworks which avoid
      using the global random state.  See e.g. #1709.
      """
      assert isinstance(seed, int)
      assert 0 <= seed < 2**32
      states: dict = {}
  
      if "numpy" in sys.modules:
          global NP_RANDOM
          if NP_RANDOM is None:
              # Protect this from garbage-collection by adding it to global scope
              NP_RANDOM = RANDOMS_TO_MANAGE[
                  next(_RKEY)
              ] = NumpyRandomWrapper()
  
      def seed_all():
          assert not states
          for k, r in RANDOMS_TO_MANAGE.items():
              states[k] = r.getstate()
              r.seed(seed)
  
      def restore_all():
          for k, state in states.items():
              r = RANDOMS_TO_MANAGE.get(k)
              if r is not None:  # i.e., hasn't been garbage-collected
                  r.setstate(state)
          states.clear()
  
      return seed_all, restore_all
  
file_path: catboost/contrib/python/hypothesis/py3/hypothesis/internal/entropy.py
imports: import contextlib
  import gc
  import random
  import sys
  import warnings
  from itertools import count
  from typing import TYPE_CHECKING, Any, Callable, Hashable, Tuple
  from weakref import WeakValueDictionary
  import hypothesis.core
  from hypothesis.errors import HypothesisWarning, InvalidArgument
  from hypothesis.internal.compat import GRAALPY, PYPY
label_desc: Use image node_id 2 for calling a global function with example usage: get_seeder_and_restorer(seed) and returns: seed_all,  restore_all