docstr: Save model weights at the provided path.
  :param filepath: String or PathLike, path to the file to save the weights to.
  When saving in TensorFlow format, this is the prefix used for checkpoint files
  (multiple files are generated). Note that the '.h5' suffix causes weights to be
  saved in HDF5 format. It can be local, hdfs, or s3 filepath.
  :param overwrite: Whether to silently overwrite any existing file at the target location,
  or provide the user with a manual prompt.
  :param save_format: Either 'tf' or 'h5'.
  A filepath ending in '.h5' or '.keras' will default to HDF5 if save_format is None.
  Otherwise None defaults to 'tf'.
docstr_tok: ["Save","model","weights","at","the","provided","path",".",":","param","filepath",":","String","or","PathLike",",","path","to","the","file","to","save","the","weights","to",".","When","saving","in","TensorFlow","format",",","this","is","the","prefix","used","for","checkpoint","files","(","multiple","files","are","generated",")",".","Note","that","the","'.h5","'","suffix","causes","weights","to","be","saved","in","HDF5","format",".","It","can","be","local",",","hdfs",",","or","s3","filepath",".",":","param","overwrite",":","Whether","to","silently","overwrite","any","existing","file","at","the","target","location",",","or","provide","the","user","with","a","manual","prompt",".",":","param","save_format",":","Either","'tf","'","or","'h5","'",".","A","filepath","ending","in","'.h5","'","or","'.keras","'","will","default","to","HDF5","if","save_format","is","None",".","Otherwise","None","defaults","to","'tf","'","."]
code: def save_weights(
      self,
      filepath: str,
      overwrite: bool = True,
      save_format: Optional[str] = None,
  ) -> None:
      """
      Save model weights at the provided path.
      :param filepath: String or PathLike, path to the file to save the weights to.
      When saving in TensorFlow format, this is the prefix used for checkpoint files
      (multiple files are generated). Note that the '.h5' suffix causes weights to be
      saved in HDF5 format. It can be local, hdfs, or s3 filepath.
      :param overwrite: Whether to silently overwrite any existing file at the target location,
      or provide the user with a manual prompt.
      :param save_format: Either 'tf' or 'h5'.
      A filepath ending in '.h5' or '.keras' will default to HDF5 if save_format is None.
      Otherwise None defaults to 'tf'.
      """
  
      # Some model might need to aggregate variables during checkpointing
      # which requires both the chief and workers to participate in the
      # allreduce communication protocol.
      # So we need to call get_state on every remote workers, otherwise
      # it might get stuck
      model = self.get_model()
      if is_local_path(filepath):
          model.save_weights(filepath, overwrite, save_format)
      else:
          file_name = os.path.basename(filepath)
          temp_dir = tempfile.mkdtemp()
          temp_path = os.path.join(temp_dir, file_name)
          try:
              model.save_weights(temp_path, overwrite, save_format)
              if (
                  save_format == "h5"
                  or filepath.endswith(".h5")
                  or filepath.endswith(".keras")
              ):
                  # hdf5 format
                  put_local_file_to_remote(temp_path, filepath)
              else:
                  # tf format
                  remote_dir = os.path.dirname(filepath)
                  put_local_files_with_prefix_to_remote(
                      temp_path, remote_dir
                  )
          finally:
              shutil.rmtree(temp_dir)
  
imports: import os
  import types
  import logging
  import tempfile
  import shutil
  from bigdl.dllib.utils.common import get_node_and_core_number
  from bigdl.dllib.utils.file_utils import is_local_path
  from bigdl.dllib.utils.utils import get_node_ip
  from bigdl.orca.data.file import is_file, exists, get_remote_file_to_local, get_remote_files_with_prefix_to_local, put_local_file_to_remote, put_local_files_with_prefix_to_remote
  from bigdl.orca.learn.tf2.spark_runner import SparkRunner
  from bigdl.orca.learn.utils import find_free_port, find_ip_and_free_port
  from bigdl.orca.learn.utils import maybe_dataframe_to_xshards, dataframe_to_xshards, convert_predict_xshards_to_dataframe, make_data_creator, load_model, save_model, process_xshards_of_pandas_dataframe, add_predict_to_pd_xshards, update_predict_xshards
  from bigdl.orca.learn.log_monitor import start_log_server, stop_log_server
  from bigdl.orca import OrcaContext
  from bigdl.orca.data.shard import SparkXShards
  from bigdl.dllib.utils.log4Error import invalidInputError
  from pyspark.sql.dataframe import DataFrame
  from typing import TYPE_CHECKING, Any, Dict, List, Callable, Union, Optional
label_desc: Use image node_id 6 for calling the SparkTFEstimator obj's underlying member method code with example usage: obj.save_weights(filepath, overwrite, save_format) without return types