class_docstr: Trainer extension to take snapshots.
  
  This extension serializes the given object and saves it to the output
  directory.
  
  This extension is called once per epoch by default. To take a
  snapshot at a different interval, a trigger object specifying the
  required interval can be passed along with this extension
  to the `extend()` method of the trainer.
  
  The default priority is -100, which is lower than that of most
  built-in extensions.
class_docstr_tok: ["Trainer","extension","to","take","snapshots",".","This","extension","serializes","the","given","object","and","saves","it","to","the","output","directory",".","This","extension","is","called","once","per","epoch","by","default",".","To","take","a","snapshot","at","a","different","interval",",","a","trigger","object","specifying","the","required","interval","can","be","passed","along","with","this","extension","to","the","`","extend","(",")","`","method","of","the","trainer",".","The","default","priority","is","-100",",","which","is","lower","than","that","of","most","built-in","extensions","."]
code: def __init__(
      self,
      target=None,
      condition=None,
      writer=None,
      filename="snapshot_iter_{.updater.iteration}",
      snapshot_on_error=False,
      n_retains=-1,
      autoload=False,
      **kwargs,
  ):
      if condition is None:
          condition = _always_true
      if writer is None:
          writer = snapshot_writers.SimpleWriter()
      if "num_retain" in kwargs:
          warnings.warn(
              "Argument `num_retain` is deprecated. "
              "Please use `n_retains` instead",
              DeprecationWarning,
          )
          n_retains = kwargs["num_retain"]
  
      self._target = target
      self.filename = filename
      self.condition = condition
      self.writer = writer
      self._snapshot_on_error = snapshot_on_error
      self.n_retains = n_retains
      self.autoload = autoload
  
imports: import os
  import warnings
  import chainer
  from chainer.serializers import npz
  from chainer.training import extension
  from chainer.training.extensions import snapshot_writers
  from chainer.utils import argument
label_desc: Use image node_id 1 to create a new _Snapshot object from inherited base classes: extension with example: obj = _Snapshot(target, condition, writer, filename, snapshot_on_error, n_retains, autoload)