code: def test_checkpoint_weights(self):
      sc = OrcaContext.get_spark_context()
      rdd = sc.range(0, 100)
      spark = OrcaContext.get_spark_session()
  
      from pyspark.ml.linalg import DenseVector
  
      df = rdd.map(
          lambda x: (
              DenseVector(
                  np.random.randn(
                      1,
                  ).astype(np.float32)
              ),
              int(np.random.randint(0, 2, size=())),
          )
      ).toDF(["feature", "label"])
  
      config = {"lr": 0.2}
  
      try:
          temp_dir = tempfile.mkdtemp()
  
          trainer = Estimator.from_keras(
              model_creator=model_creator,
              verbose=True,
              config=config,
              workers_per_node=2,
              backend="spark",
          )
  
          callbacks = [
              tf.keras.callbacks.ModelCheckpoint(
                  filepath=os.path.join(temp_dir, "ckpt_{epoch}"),
                  save_weights_only=True,
              )
          ]
  
          res = trainer.fit(
              df,
              epochs=3,
              batch_size=4,
              steps_per_epoch=25,
              callbacks=callbacks,
              feature_cols=["feature"],
              label_cols=["label"],
              validation_data=df,
              validation_steps=1,
          )
          latest_checkpoint = Estimator.latest_checkpoint(temp_dir)
          trainer.load_weights(latest_checkpoint)
          res = trainer.evaluate(
              df,
              batch_size=4,
              num_steps=25,
              feature_cols=["feature"],
              label_cols=["label"],
          )
          print("validation result: ", res)
  
          res = trainer.predict(df, feature_cols=["feature"]).collect()
          print("predict result: ", res)
      finally:
          shutil.rmtree(temp_dir)
  
imports: import os
  import pytest
  import shutil
  import tempfile
  from unittest import TestCase
  import numpy
  import tensorflow
  from bigdl.orca import init_orca_context, stop_orca_context
  from bigdl.orca.learn.tf2 import Estimator
  from bigdl.orca import OrcaContext
label_desc: Use image node_id 4 for calling the TestTFEstimatorBasic obj's underlying member method code with example usage: obj.test_checkpoint_weights() without return types