code: def test_update(self):
      # Create a barrier to be shared between the test body and the variable
      # source. The barrier will block until, in this case, two threads call
      # wait(). Note that the (fake) variable source will call it within its
      # get_variables() call.
      barrier = threading.Barrier(2)
  
      # Create a variable source (emulating the learner).
      np_learner_variables = tf2_utils.to_numpy(
          self._learner_model.variables
      )
      variable_source = fakes.VariableSource(
          np_learner_variables, barrier
      )
  
      # Create a variable client (emulating the actor).
      variable_client = tf2_variable_utils.VariableClient(
          variable_source,
          {"policy": self._actor_model.variables},
          update_period=_UPDATE_PERIOD,
      )
  
      # Create some random batch of test input:
      x = tf.random.normal(shape=(_BATCH_SIZE, _INPUT_SIZE))
  
      # Create variables by doing the computation once.
      learner_output = self._learner_model(x)
      actor_output = self._actor_model(x)
      del learner_output, actor_output
  
      for _ in range(_UPDATE_PERIOD):
          # Before the update period is reached, the models have different outputs.
          self.assertNotAllClose(
              self._actor_model.variables, self._learner_model.variables
          )
  
          # Before the update period is reached, the variable client should not make
          # any requests for variables.
          self.assertIsNone(variable_client._future)
  
          variable_client.update()
  
      # Make sure the last call created a request for variables and reset the
      # internal call counter.
      self.assertIsNotNone(variable_client._future)
      self.assertEqual(variable_client._call_counter, 0)
      future = variable_client._future
  
      for _ in range(_UPDATE_PERIOD):
          # Before the barrier allows the variables to be released, the models have
          # different outputs.
          self.assertNotAllClose(
              self._actor_model.variables, self._learner_model.variables
          )
  
          variable_client.update()
  
          # Make sure no new requests are made.
          self.assertEqual(variable_client._future, future)
  
      # Calling wait() on the barrier will now allow the variables to be copied
      # over from source to client.
      barrier.wait()
  
      # Update once more to ensure the variables are copied over.
      while variable_client._future is not None:
          variable_client.update()
  
      # After a number of update calls, the variables should be the same.
      self.assertAllClose(
          self._actor_model.variables, self._learner_model.variables
      )
  
file_path: acme/acme/tf/variable_utils_test.py
imports: import threading
  from acme.testing import fakes
  from acme.tf import utils
  from acme.tf import variable_utils
  import sonnet
  import tensorflow
label_desc: Use image node_id 3 for calling the VariableClientTest obj's underlying member method code with example usage: obj.test_update() without return types