code: def test_optional_model_creator_savemodel(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",
          )
  
          trainer.fit(
              df,
              epochs=5,
              batch_size=4,
              steps_per_epoch=25,
              feature_cols=["feature"],
              label_cols=["label"],
              validation_data=df,
              validation_steps=1,
          )
  
          # save model as savemodel format
          trainer.save(os.path.join(temp_dir, "saved_model"))
          before_res = trainer.predict(
              df, feature_cols=["feature"]
          ).collect()
          expect_res = np.concatenate(
              [part["prediction"] for part in before_res]
          )
          trainer.shutdown()
  
          est = Estimator.from_keras(
              verbose=True,
              config=config,
              workers_per_node=2,
              backend="spark",
          )
  
          est.load(os.path.join(temp_dir, "saved_model"))
          # test continous predicting
          after_res = est.predict(
              df, feature_cols=["feature"]
          ).collect()
          pred_res = np.concatenate(
              [part["prediction"] for part in after_res]
          )
          assert np.array_equal(expect_res, pred_res)
  
          # test continuous training
          est.fit(
              df,
              epochs=5,
              batch_size=4,
              steps_per_epoch=25,
              feature_cols=["feature"],
              label_cols=["label"],
              validation_data=df,
              validation_steps=1,
          )
          # test continuous evaluation
          res = est.evaluate(
              df,
              batch_size=4,
              num_steps=25,
              feature_cols=["feature"],
              label_cols=["label"],
          )
          print("validation 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.learn.tf2 import Estimator
  from bigdl.orca import OrcaContext
label_desc: Use image node_id 8 for calling the TestTF2Estimator obj's underlying member method code with example usage: obj.test_optional_model_creator_savemodel() without return types