code: def _async_save(
      state_dict: STATE_DICT_TYPE,
      storage_writer: StorageWriter,
      *,
      process_group: Optional[dist.ProcessGroup] = None,
      coordinator_rank: int = 0,
      no_dist: bool = False,
      planner: Optional[SavePlanner] = None,
  ) -> Future:
      """Asynchronous version of ``save_state_dict``. This code first de-stages the state_dict on CPU, and then calls
      `save` in a separate thread.
  
      .. warning::
          This feature is experimental and subject to removal/change.
  
      Args:
          state_dict (Dict[str, Any]): The state_dict to save.
          storage_writer (StorageWriter):
              Instance of StorageWrite use to perform writes.
          process_group (ProcessGroup):
              ProcessGroup to be used for cross-rank synchronization.
          coordinator_rank (int): Rank to use to coordinate the checkpoint.
              rank0 is used by default.
          no_dist (bool): If ``True``, distributed checkpoint will not save
              in SPMD style. (Default: ``False``)
  
      Returns:
          Future: A future holding the resultant Metadata object from `save`.
  
      """
      torch._C._log_api_usage_once(
          "torch.distributed.checkpoint._async_save"
      )
  
      cpu_state_dict = _offload_state_dict_to_cpu(
          _stateful_to_state_dict(state_dict)
      )
  
      executor = ThreadPoolExecutor(max_workers=1)
      f = executor.submit(
          _save_state_dict,
          cpu_state_dict,
          storage_writer,
          process_group,
          coordinator_rank,
          no_dist,
          planner,
      )
      f.add_done_callback(lambda f: executor.shutdown(wait=False))
  
      return f
  
file_path: pytorch/torch/distributed/checkpoint/state_dict_saver.py
imports: import warnings
  from concurrent.futures import Future, ThreadPoolExecutor
  from typing import Optional
  import torch
  import torch.distributed
  from torch.distributed._state_dict_utils import _offload_state_dict_to_cpu
  from torch.distributed.checkpoint.stateful import Stateful
  from .default_planner import DefaultSavePlanner
  from .metadata import Metadata, STATE_DICT_TYPE
  from .planner import SavePlanner
  from .storage import StorageWriter
  from .utils import _DistWrapper, _profile
label_desc: Use image node_id 3 for calling a global function with example usage: _async_save(state_dict, storage_writer) and returns: f