code: def test_checkpointing():
      """Test loading and saving checkpoints with KerasModel."""
      # Create two models using the same model directory.
  
      keras_model1 = tf.keras.Sequential([tf.keras.layers.Dense(10)])
      keras_model2 = tf.keras.Sequential([tf.keras.layers.Dense(10)])
      model1 = dc.models.KerasModel(
          keras_model1, dc.models.losses.L2Loss()
      )
      model2 = dc.models.KerasModel(
          keras_model2,
          dc.models.losses.L2Loss(),
          model_dir=model1.model_dir,
      )
  
      # Check that they produce different results.
  
      X = np.random.rand(5, 5)
      y1 = model1.predict_on_batch(X)
      y2 = model2.predict_on_batch(X)
      assert not np.array_equal(y1, y2)
  
      # Save a checkpoint from the first model and load it into the second one,
      # and make sure they now match.
  
      model1.save_checkpoint()
      model2.restore()
      y3 = model1.predict_on_batch(X)
      y4 = model2.predict_on_batch(X)
      assert np.array_equal(y1, y3)
      assert np.array_equal(y1, y4)
  
file_path: deepchem/deepchem/models/tests/test_kerasmodel.py
imports: import os
  import math
  import deepchem
  import numpy
  import unittest
  import pytest
label_desc: Use image node_id 5 for calling a global function with example usage: test_checkpointing() without return types