code: def preserve_random_generator_state():
      numpy_state = np.random.get_state()
      random_state = random.getstate()
      yield
      np.random.set_state(numpy_state)
      random.setstate(random_state)
  
imports: import random
  import networkx
  import numpy
  import pandas
  import pytest
  from _pytest.python_api import approx
  from dowhy import gcm
  from dowhy.gcm.util.general import apply_catboost_encoding, apply_one_hot_encoding, auto_apply_encoders, auto_fit_encoders, fit_catboost_encoders, fit_one_hot_encoders, has_categorical, is_categorical, is_discrete, set_random_seed, setdiff2d, shape_into_2d
label_desc: Use image node_id 1 for calling a global function with example usage: preserve_random_generator_state() without return types