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)
  
file_path: dowhy/tests/gcm/independence_test/test_generalised_cov_measure.py
imports: import random
  import numpy
  import pytest
  from flaky import flaky
  from dowhy.gcm import generalised_cov_based
  from tests.gcm.independence_test.test_kernel import _generate_categorical_data
label_desc: Use image node_id 1 for calling a global function with example usage: preserve_random_generator_state() without return types