class_docstr: Handler that saves input checkpoint on a disk.
  
  Args:
      dirname: Directory path where the checkpoint will be saved
      atomic: if True, checkpoint is serialized to a temporary file, and then
          moved to final destination, so that files are guaranteed to not be damaged
          (for example if exception occurs during saving).
      create_dir: if True, will create directory ``dirname`` if it doesnt exist.
      require_empty: If True, will raise exception if there are any files in the
          directory ``dirname``.
      save_on_rank: The rank on which the checkpoint will be saved. Used in distributed
          configuration.
      kwargs: Accepted keyword arguments for `torch.save` or `xm.save`.
  
  .. versionchanged:: 0.4.2
      Accept ``kwargs`` for `torch.save` or `xm.save`.
  
  .. versionchanged:: 0.4.10
      Argument ``save_on_rank`` was added to specify the rank on which checkpoint should be saved.
class_docstr_tok: ["Handler","that","saves","input","checkpoint","on","a","disk",".","Args",":","dirname",":","Directory","path","where","the","checkpoint","will","be","saved","atomic",":","if","True",",","checkpoint","is","serialized","to","a","temporary","file",",","and","then","moved","to","final","destination",",","so","that","files","are","guaranteed","to","not","be","damaged","(","for","example","if","exception","occurs","during","saving",")",".","create_dir",":","if","True",",","will","create","directory","``","dirname","``","if","it","doesnt","exist",".","require_empty",":","If","True",",","will","raise","exception","if","there","are","any","files","in","the","directory","``","dirname","``",".","save_on_rank",":","The","rank","on","which","the","checkpoint","will","be","saved",".","Used","in","distributed","configuration",".","kwargs",":","Accepted","keyword","arguments","for","`","torch.save","`","or","`","xm.save","`",".","..","versionchanged",":",":","0.4.2","Accept","``","kwargs","``","for","`","torch.save","`","or","`","xm.save","`",".","..","versionchanged",":",":","0.4.10","Argument","``","save_on_rank","``","was","added","to","specify","the","rank","on","which","checkpoint","should","be","saved","."]
code: def __init__(
      self,
      dirname: Union[str, Path],
      atomic: bool = True,
      create_dir: bool = True,
      require_empty: bool = True,
      save_on_rank: int = 0,
      **kwargs: Any,
  ):
      self.dirname = Path(dirname).expanduser()
      self._atomic = atomic
      self.save_on_rank = save_on_rank
  
      if idist.get_rank() == save_on_rank:
          self._check_and_setup(self.dirname, create_dir, require_empty)
      self.kwargs = kwargs
  
imports: import collections.abc
  import numbers
  import os
  import stat
  import tempfile
  from abc import ABCMeta, abstractmethod
  from collections import OrderedDict
  from pathlib import Path
  from typing import Any, Callable, cast, Dict, List, Mapping, NamedTuple, Optional, Union
  import torch
  import torch.nn
  from packaging.version import Version
  import ignite.distributed
  from ignite.base import Serializable
  from ignite.engine import Engine, Events
  from ignite.utils import _tree_apply2, _tree_map
label_desc: Use image node_id 1 to create a new DiskSaver object from inherited base classes: BaseSaveHandler with example: obj = DiskSaver(dirname, atomic, create_dir, require_empty, save_on_rank)