class_docstr: Convenience class for periodically snapshotting.
  
  Objects which can be snapshotted are limited to Sonnet or tensorflow Modules
  which implement a __call__ method. This will save the module's graph and
  variables such that they can be loaded later using `tf.saved_model.load`. See
  https://www.tensorflow.org/guide/saved_model for more details.
  
  The Snapshotter is typically used to save infrequent permanent self-contained
  snapshots which can be loaded later for inspection. For frequent saving of
  model parameters in order to guard against pre-emption of the learning process
  see the Checkpointer class.
  
  Usage example:
  
  ```python
  model = snt.Linear(10)
  snapshotter = Snapshotter(objects_to_save={'model': model})
  
  for _ in range(100):
    # ...
    snapshotter.save()
  ```
class_docstr_tok: ["Convenience","class","for","periodically","snapshotting",".","Objects","which","can","be","snapshotted","are","limited","to","Sonnet","or","tensorflow","Modules","which","implement","a","__call__","method",".","This","will","save","the","module","'s","graph","and","variables","such","that","they","can","be","loaded","later","using","`","tf.saved_model.load","`",".","See","https",":","\/\/www.tensorflow.org\/guide\/saved_model","for","more","details",".","The","Snapshotter","is","typically","used","to","save","infrequent","permanent","self-contained","snapshots","which","can","be","loaded","later","for","inspection",".","For","frequent","saving","of","model","parameters","in","order","to","guard","against","pre-emption","of","the","learning","process","see","the","Checkpointer","class",".","Usage","example",":","``","`","python","model","=","snt.Linear","(","10",")","snapshotter","=","Snapshotter","(","objects_to_save=","{","'model","'",":","model","}",")","for","_","in","range","(","100",")",":","#","...","snapshotter.save","(",")","``","`"]
docstr: Builds the saver object.
  
  Args:
    objects_to_save: Mapping specifying what to snapshot.
    directory: Which directory to put the snapshot in.
    time_delta_minutes: How often to save the snapshot, in minutes.
    snapshot_ttl_seconds: TTL (time to leave) in seconds for snapshots.
docstr_tok: ["Builds","the","saver","object",".","Args",":","objects_to_save",":","Mapping","specifying","what","to","snapshot",".","directory",":","Which","directory","to","put","the","snapshot","in",".","time_delta_minutes",":","How","often","to","save","the","snapshot",",","in","minutes",".","snapshot_ttl_seconds",":","TTL","(","time","to","leave",")","in","seconds","for","snapshots","."]
code: def __init__(
      self,
      objects_to_save: Mapping[str, snt.Module],
      *,
      directory: str = "~/acme/",
      time_delta_minutes: float = 30.0,
      snapshot_ttl_seconds: int = _DEFAULT_SNAPSHOT_TTL,
  ):
      """Builds the saver object.
  
      Args:
        objects_to_save: Mapping specifying what to snapshot.
        directory: Which directory to put the snapshot in.
        time_delta_minutes: How often to save the snapshot, in minutes.
        snapshot_ttl_seconds: TTL (time to leave) in seconds for snapshots.
      """
      objects_to_save = objects_to_save or {}
  
      self._time_delta_minutes = time_delta_minutes
      self._last_saved = 0.0
      self._snapshots = {}
  
      # Save the base directory path so we can refer to it if needed.
      self.directory = paths.process_path(
          directory, "snapshots", ttl_seconds=snapshot_ttl_seconds
      )
  
      # Save a dictionary mapping paths to snapshot capable models.
      for name, module in objects_to_save.items():
          path = os.path.join(self.directory, name)
          self._snapshots[path] = make_snapshot(module)
  
imports: import abc
  import datetime
  import os
  import pickle
  import time
  from typing import Mapping, Optional, Union
  from absl import logging
  from acme import core
  from acme.utils import signals
  from acme.utils import paths
  import sonnet
  import tensorflow
  import tree
  from tensorflow.python.saved_model import revived_types
label_desc: Use image node_id 1 to create a new Snapshotter object  with example: obj = Snapshotter(objects_to_save)