class_docstr: A set of tests for the Learner.
class_docstr_tok: ["A","set","of","tests","for","the","Learner","."]
code: def testInitialCheckpointStoresOptimizerVariables(
      self, create_agent_fn, strategy_fn, per_core_batch_size
  ):
      # Create strategy. Skip the test if the strategy is unsupported.
      strategy = strategy_fn()
      if strategy is None:
          logging.info(
              (
                  "The strategy created using the function %s is not "
                  "supported. Skipping the test."
              ),
              strategy_fn,
          )
  
      # Create learner.
      base_dir = self.create_tempdir().full_path
      root_dir = os.path.join(base_dir, "root_dir")
      trained_learner = self._build_learner_with_strategy(
          create_agent_fn,
          strategy,
          per_core_batch_size,
          root_dir=root_dir,
      )[0]
  
      # Force saving initial checkpoint.
      trained_learner._checkpointer.save(trained_learner.train_step)
      self.assertLen(
          trained_learner._checkpointer.manager.checkpoints, 1
      )
  
      # Make a copy of the initial root directory.
      initial_root_dir = os.path.join(base_dir, "initial_root_dir")
      _copy_recursive(root_dir, initial_root_dir)
  
      # Run one step of training which creates another checkpoint.
      trained_learner.run(iterations=1)
      self.assertLen(
          trained_learner._checkpointer.manager.checkpoints, 2
      )
      trained_learner = self._build_learner_with_strategy(
          create_agent_fn,
          strategy,
          per_core_batch_size,
          root_dir=root_dir,
      )[0]
      self.assertLen(
          trained_learner._checkpointer.manager.checkpoints, 2
      )
  
      # Create another learner with the initial checkpoint.
      initial_learner_from_checkpoint = (
          self._build_learner_with_strategy(
              create_agent_fn,
              strategy,
              per_core_batch_size,
              root_dir=initial_root_dir,
          )[0]
      )
      self.assertLen(
          initial_learner_from_checkpoint._checkpointer.manager.checkpoints,
          1,
      )
  
      # Both of the learners should contain the optimizer variable values which
      # should be different.
      initial_optimizer_vars = (
          initial_learner_from_checkpoint._agent._optimizer.variables()
      )
      self.assertNotEmpty(initial_optimizer_vars)
      self.assertEqual(
          initial_optimizer_vars[0].numpy(), 0
      )  # Adam/iter:0
  
      trained_optimizer_vars = (
          trained_learner._agent._optimizer.variables()
      )
      self.assertNotEmpty(trained_optimizer_vars)
      self.assertEqual(
          trained_optimizer_vars[0].numpy(), 1
      )  # Adam/iter:0
  
      # Not all of the values should be close to each other.
      num_asserts = 0
      for initial, after_train_step in zip(
          initial_optimizer_vars, trained_optimizer_vars
      ):
          name_parts = initial.name.split("/")
          if (
              "bias" in name_parts
              or "EncodingNetwork" in name_parts
              or "NormalProjectionNetwork" in name_parts
          ):
              # These always seem to be zero. Let's skip them.
              continue
          self.assertNotAllClose(
              initial.numpy(),
              after_train_step.numpy(),
              atol=1.0e-12,
              rtol=1.0e-12,
              msg="The {} and {} are close at each element: {}.".format(
                  initial.name, after_train_step.name, initial
              ),
          )
          num_asserts += 1
  
      # The value of `Adam/iter:0` is already compared above. There always should
      # be more assertions associated with this test.
      self.assertGreater(num_asserts, 1)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import os
  from absl import logging
  from absl.testing import parameterized
  import numpy
  from six.moves import range
  import tensorflow
  from tf_agents.agents.behavioral_cloning import behavioral_cloning_agent
  from tf_agents.environments import suite_gym
  from tf_agents.environments import tf_py_environment
  from tf_agents.keras_layers import inner_reshape
  from tf_agents.networks import sequential
  from tf_agents.specs import tensor_spec
  from tf_agents.system import system_multiprocessing
  from tf_agents.train import learner
  from tf_agents.train.utils import test_utils
  from tf_agents.train.utils import train_utils
  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 9 for calling the LearnerTest obj's underlying member method code with example usage: obj.testInitialCheckpointStoresOptimizerVariables(create_agent_fn, strategy_fn, per_core_batch_size) without return types