code: def save_model(
      model,
      filepath,
      overwrite=True,
      include_optimizer=True,
      save_format=None,
      signatures=None,
      options=None,
      filemode=None,
  ):
      if is_local_path(filepath):
          model.save(
              filepath,
              overwrite=overwrite,
              include_optimizer=include_optimizer,
              save_format=save_format,
              signatures=signatures,
              options=options,
          )
      else:
          file_name = os.path.basename(filepath)
          temp_dir = tempfile.mkdtemp()
          temp_path = os.path.join(temp_dir, file_name)
          try:
              model.save(
                  temp_path,
                  overwrite=overwrite,
                  include_optimizer=include_optimizer,
                  save_format=save_format,
                  signatures=signatures,
                  options=options,
              )
              if (
                  save_format == "h5"
                  or filepath.endswith(".h5")
                  or filepath.endswith(".keras")
              ):
                  # hdf5 format
                  put_local_file_to_remote(
                      temp_path, filepath, filemode
                  )
              else:
                  # tf format
                  put_local_dir_tree_to_remote(temp_path, filepath)
          finally:
              shutil.rmtree(temp_dir)
  
imports: from contextlib import closing
  import socket
  import sys
  import tempfile
  import shutil
  from bigdl.dllib.utils import log4Error
  from bigdl.dllib.utils.common import callBigDlFunc
  from bigdl.dllib.utils.file_utils import get_file_list, is_local_path
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.utils import get_size
  from bigdl.orca.data.file import put_local_dir_tree_to_remote, put_local_file_to_remote, get_remote_file_to_local, get_remote_dir_to_local
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from functools import partial
  import numpy
  from bigdl.orca.common import SafePickle
  import os
  import subprocess
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 38 for calling a global function with example usage: save_model(model, filepath, overwrite, include_optimizer, save_format, signatures, options, filemode) without return types