class_docstr: Base class of snapshot writers.
  
  :class:`~chainer.training.extensions.Snapshot` invokes ``__call__`` of this
  class every time when taking a snapshot.
  This class determines how the actual saving function will be invoked.
  
  .. seealso::
  
      - :meth:`chainer.training.extensions.snapshot`
docstr: Adds cleanup hook function.
  
  Technically, arbitrary user-defined hook can be called, but
  this is intended for cleaning up stale snapshots.
  
  Args:
      hook_fun (callable): callable function to be called
          right after save is done. It takes no arguments.
docstr_tok: ["Adds","cleanup","hook","function",".","Technically",",","arbitrary","user-defined","hook","can","be","called",",","but","this","is","intended","for","cleaning","up","stale","snapshots",".","Args",":","hook_fun","(","callable",")",":","callable","function","to","be","called","right","after","save","is","done",".","It","takes","no","arguments","."]
code: def _add_cleanup_hook(self, hook_fun):
      """Adds cleanup hook function.
  
      Technically, arbitrary user-defined hook can be called, but
      this is intended for cleaning up stale snapshots.
  
      Args:
          hook_fun (callable): callable function to be called
              right after save is done. It takes no arguments.
  
      """
      self._post_save_hooks.append(hook_fun)
  
imports: import multiprocessing
  import os
  import shutil
  import threading
  from six.moves import queue
  from chainer.serializers import npz
  from chainer import utils
label_desc: Use image node_id 6 for calling the Writer obj's underlying member method code with example usage: obj._add_cleanup_hook(hook_fun) without return types