class_docstr: Unit tests for variable tracing using.
code: def test_closure_overrides_global_vars(self):
      # Make sure that global variables are what we expect them to be
      np.testing.assert_allclose(global_w.value, np.zeros(5))
      np.testing.assert_allclose(global_b.value, np.zeros(1))
  
      def _do_test():
          # define local variable with the same name as existing global
          global_w = objax.TrainVar(jn.ones(10))
  
          # verify that global_w and global_b are what we expect them to be
          np.testing.assert_allclose(global_w.value, np.ones(10))
          np.testing.assert_allclose(global_b.value, np.zeros(1))
  
          # loss function which mixes closure vars, global vars and closure var hides global var
          def loss(x, y):
              pred = jn.dot(x, global_w.value) + global_b.value
              return 0.5 * ((y - pred) ** 2).mean()
  
          vc = objax.util.find_used_variables(loss)
          self.assertDictEqual(
              vc, {"global_w": global_w, "global_b": global_b}
          )
  
      _do_test()
  
      # Make sure that global variables didn't change, in other words
      # that _do_test operated on local variables
      np.testing.assert_allclose(global_w.value, np.zeros(5))
      np.testing.assert_allclose(global_b.value, np.zeros(1))
  
file_path: objax/tests/tracing.py
imports: import unittest
  import numpy
  import jax.numpy
  import objax
  from objax.zoo.dnnet import DNNet
label_desc: Use image node_id 7 for calling the TestTracing obj's underlying member method code with example usage: obj.test_closure_overrides_global_vars() and returns: unknown