class_docstr: Adds test methods running standard checkpointing tests.
docstr: Checks that a checkpoint created for one instance can restore another.
docstr_tok: ["Checks","that","a","checkpoint","created","for","one","instance","can","restore","another","."]
code: def test_save_then_load_new_instance(self, golden):
      """Checks that a checkpoint created for one instance can restore another."""
      module_1 = golden.create_module()
      checkpoint_1 = TestCheckpoint(module=module_1)
      variables_1 = golden.create_all_variables(module_1)
  
      module_2 = golden.create_module()
      checkpoint_2 = TestCheckpoint(module=module_2)
      variables_2 = golden.create_all_variables(module_2)
  
      for v1, v2 in zip(variables_1, variables_2):
          v1.assign(goldens.range_like(v1))
          v2.assign(tf.ones_like(v2))
  
      checkpoint_1.save()
      checkpoint_2.restore_latest(assert_consumed=True)
  
      # Assert the parameters in both modules are the same.
      for variable in variables_2:
          self.assertAllClose(
              variable.read_value(),
              goldens.range_like(variable),
              msg=variable.name,
          )
  
      # Assert the output from both modules are the same.
      if golden.deterministic:
          tree.map_structure(
              self.assertAllClose,
              golden.forward(module_1),
              golden.forward(module_2),
          )
  
imports: import os
  from absl import logging
  from absl.testing import absltest
  from absl.testing import parameterized
  from sonnet.src import test_utils
  from sonnet.src.conformance import goldens
  from sonnet.src.distribute import replicator
  from sonnet.src.distribute import replicator_test_utils
  import tensorflow
  import tree
label_desc: Use image node_id 2 for calling the GoldenCheckpointsTest obj's underlying member method code with example usage: obj.test_save_then_load_new_instance(golden) without return types