class_docstr: Helper class for async checkpoint.
class_docstr_tok: ["Helper","class","for","async","checkpoint","."]
docstr: Save the checkpointed variables.
  
  This method has exactly the same logic as save(), except it does not
  increment the underlying save_counter, which is done by the caller, e.g.,
  CheckpointManager.
  
  Args:
    save_path: The file prefix of the checkpoint file.
    options: Optional CheckpointOption instance.
  
  Returns:
    The full path of the checkpoint file.
docstr_tok: ["Save","the","checkpointed","variables",".","This","method","has","exactly","the","same","logic","as","save","(",")",",","except","it","does","not","increment","the","underlying","save_counter",",","which","is","done","by","the","caller",",","e.g.",",","CheckpointManager",".","Args",":","save_path",":","The","file","prefix","of","the","checkpoint","file",".","options",":","Optional","CheckpointOption","instance",".","Returns",":","The","full","path","of","the","checkpoint","file","."]
code: def _write(self, save_path, options=None):
      """Save the checkpointed variables.
  
      This method has exactly the same logic as save(), except it does not
      increment the underlying save_counter, which is done by the caller, e.g.,
      CheckpointManager.
  
      Args:
        save_path: The file prefix of the checkpoint file.
        options: Optional CheckpointOption instance.
  
      Returns:
        The full path of the checkpoint file.
      """
      write_start_time = time.time()
  
      if not self._initialized:
          self._ensure_initialized()
      else:
          # First wait for async thread to finish the previous save, then copy the
          # variable values to the host CPU.
          self._queue.join()
          self._copy_to_cpu()
  
      # Surface the error from the async thread, if any.
      # This step should come after the sem acquision step in the above, so that
      # it makes sure it waits until the previous async save finishes storing the
      # error.
      self._check_async_thread_error()
  
      # Trigger the async thread to checkpoint the cpu-copied variables.
      # Need to wait until the weight copying finishes before checkpoint save.
      context.async_wait()
      self._save_file_prefix = save_path
      self._use_checkpoint_save = False
  
      # Ensure that we do not request async checkpointing to the underlying
      # checkpointer as this could lead to an infinite loop.
      self._checkpoint_options = copy.copy(options) if options else None
      if self._checkpoint_options:
          self._checkpoint_options.experimental_enable_async_checkpoint = (
              False
          )
  
      self._queue.put(True)  # Trigger save in async thread
  
      write_end_time = time.time()
      metrics.AddCheckpointWriteDuration(
          api_label=_ASYNC_CHECKPOINT,
          microseconds=_get_duration_microseconds(
              write_start_time, write_end_time
          ),
      )
  
      return save_path
  
imports: import atexit
  import copy
  import queue
  import threading
  import time
  import weakref
  from absl import logging
  from tensorflow.python.checkpoint import checkpoint_context
  from tensorflow.python.checkpoint import trackable_view
  from tensorflow.python.distribute import device_util
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import executor
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import variables
  from tensorflow.python.saved_model.pywrap_saved_model import metrics
  from tensorflow.python.trackable import base
  from tensorflow.python.util import object_identity
label_desc: Use image node_id 11 for calling the AsyncCheckpointHelper obj's underlying member method code with example usage: obj._write(save_path, options) and returns: save_path