code: def testUpdateWithCompositeSavedModelAndCheckpoint(self):
      # Create and saved_model for a q_policy.
      network = q_network.QNetwork(
          input_tensor_spec=self._time_step_spec.observation,
          action_spec=self._action_spec,
      )
  
      policy = q_policy.QPolicy(
          time_step_spec=self._time_step_spec,
          action_spec=self._action_spec,
          q_network=network,
      )
  
      train_step = common.create_variable("train_step", initial_value=0)
      saver = policy_saver.PolicySaver(
          policy, train_step=train_step, batch_size=None
      )
      full_model_path = os.path.join(self.get_temp_dir(), "save_model")
  
      def assert_val_equal_var(val, var):
          self.assertTrue(np.array_equal(np.full_like(var, val), var))
  
      self.evaluate(tf.compat.v1.global_variables_initializer())
      # Set all variables in the saved model to 1
      variables = policy.variables()
      self.evaluate(
          tf.nest.map_structure(
              lambda v: v.assign(v * 0 + 1), variables
          )
      )
      for v in self.evaluate(variables):
          assert_val_equal_var(1, v)
      with self.cached_session():
          saver.save(full_model_path)
  
      # Assign 2 to all variables in the policy. Making checkpoint different than
      # the initial saved_model.
      self.evaluate(
          tf.nest.map_structure(
              lambda v: v.assign(v * 0 + 2), variables
          )
      )
      for v in self.evaluate(variables):
          assert_val_equal_var(2, v)
      checkpoint_path = os.path.join(self.get_temp_dir(), "checkpoint")
      with self.cached_session():
          saver.save_checkpoint(checkpoint_path)
  
      # Reload the full model and check all variables are 1
      reloaded_policy = tf.compat.v2.saved_model.load(full_model_path)
      self.evaluate(
          tf.compat.v1.initializers.variables(
              reloaded_policy.model_variables
          )
      )
      for v in self.evaluate(reloaded_policy.model_variables):
          assert_val_equal_var(1, v)
  
      # Compose a new full saved model from the original saved model files
      # and variables from the checkpoint.
      composite_path = os.path.join(
          self.get_temp_dir(), "composite_model"
      )
      self.copy_tree(
          full_model_path, composite_path, skip_variables=True
      )
      self.copy_tree(checkpoint_path, os.path.join(composite_path))
  
      # Reload the composite model and check all variables are 2
      reloaded_policy = tf.compat.v2.saved_model.load(composite_path)
      self.evaluate(
          tf.compat.v1.initializers.variables(
              reloaded_policy.model_variables
          )
      )
      for v in self.evaluate(reloaded_policy.model_variables):
          assert_val_equal_var(2, v)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import shutil
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.networks import actor_distribution_network
  from tf_agents.networks import q_network
  from tf_agents.networks import q_rnn_network
  from tf_agents.policies import actor_policy
  from tf_agents.policies import policy_saver
  from tf_agents.policies import q_policy
  from tf_agents.policies import tf_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.utils import common
  from tf_agents.utils import test_utils
label_desc: Use image node_id 20 for calling the PolicySaverTest obj's underlying member method code with example usage: obj.testUpdateWithCompositeSavedModelAndCheckpoint() without return types