code: def train_and_save():
      autodist = AutoDist(resource_spec_file=filepath)
      with tf.Graph().as_default(), autodist.scope():
          train_dataset = (
              tf.data.Dataset.from_tensor_slices(
                  (train_images, train_labels)
              )
              .repeat(EPOCHS)
              .shuffle(len(train_images) // 2)
              .batch(BATCH_SIZE)
          )
  
          train_iterator = tf.compat.v1.data.make_one_shot_iterator(
              train_dataset
          ).get_next()
          fetches = train_step(train_iterator)
  
          saver = autodist_saver()
          sess = autodist.create_distributed_session()
          for step in range(
              min(10, len(train_images) // BATCH_SIZE * EPOCHS)
          ):
              loss, _ = sess.run(fetches)
              print(f"train_loss: {loss}")
  
          if not os.path.exists(checkpoint_dir):
              os.makedirs(checkpoint_dir)
          checkpoint_suffix = "mnist"
          checkpoint_name = checkpoint_dir + checkpoint_suffix
          saver.save(sess, checkpoint_name, global_step=step)
          saver.restore(
              sess, tf.train.latest_checkpoint(checkpoint_dir)
          )
          print("Checkpoint saved at {%s}" % checkpoint_name)
  
file_path: autodist/tests/checkpoint/test_keras_saver.py
imports: import os
  import atexit
  import numpy
  import tensorflow
  from multiprocessing import Process
  from autodist import AutoDist
  from autodist.checkpoint.saver import Saver
label_desc: Use image node_id 3 for calling a global function with example usage: train_and_save() without return types