class_docstr: Manages multiple checkpoints by keeping some and deleting unneeded ones.
  
  Example usage:
  
  ```python
  import tensorflow as tf
  checkpoint = tf.train.Checkpoint(optimizer=optimizer, model=model)
  manager = tf.train.CheckpointManager(
      checkpoint, directory="/tmp/model", max_to_keep=5)
  status = checkpoint.restore(manager.latest_checkpoint)
  while True:
    # train
    manager.save()
  ```
  
  `CheckpointManager` preserves its own state across instantiations (see the
  `__init__` documentation for details). Only one should be active in a
  particular directory at a time.
class_docstr_tok: ["Manages","multiple","checkpoints","by","keeping","some","and","deleting","unneeded","ones",".","Example","usage",":","``","`","python","import","tensorflow","as","tf","checkpoint","=","tf.train.Checkpoint","(","optimizer=optimizer",",","model=model",")","manager","=","tf.train.CheckpointManager","(","checkpoint",",","directory=","''","\/tmp\/model","''",",","max_to_keep=5",")","status","=","checkpoint.restore","(","manager.latest_checkpoint",")","while","True",":","#","train","manager.save","(",")","``","`","`","CheckpointManager","`","preserves","its","own","state","across","instantiations","(","see","the","`","__init__","`","documentation","for","details",")",".","Only","one","should","be","active","in","a","particular","directory","at","a","time","."]
docstr: Restore items in `checkpoint` from the latest checkpoint file.
  
  This method will first try to restore from the most recent checkpoint in
  `directory`. If no checkpoints exist in `directory`, and `init_fn` is
  specified, this method will call `init_fn` to do customized
  initialization. This can be used to support initialization from pretrained
  models.
  
  Note that unlike `tf.train.Checkpoint.restore()`, this method doesn't return
  a load status object that users can run assertions on
  (e.g. assert_consumed()). Thus to run assertions, users should directly use
  `tf.train.Checkpoint.restore()` method.
  
  Returns:
    The restored checkpoint path if the lastest checkpoint is found and
    restored. Otherwise None.
docstr_tok: ["Restore","items","in","`","checkpoint","`","from","the","latest","checkpoint","file",".","This","method","will","first","try","to","restore","from","the","most","recent","checkpoint","in","`","directory","`",".","If","no","checkpoints","exist","in","`","directory","`",",","and","`","init_fn","`","is","specified",",","this","method","will","call","`","init_fn","`","to","do","customized","initialization",".","This","can","be","used","to","support","initialization","from","pretrained","models",".","Note","that","unlike","`","tf.train.Checkpoint.restore","(",")","`",",","this","method","does","n't","return","a","load","status","object","that","users","can","run","assertions","on","(","e.g",".","assert_consumed","(",")",")",".","Thus","to","run","assertions",",","users","should","directly","use","`","tf.train.Checkpoint.restore","(",")","`","method",".","Returns",":","The","restored","checkpoint","path","if","the","lastest","checkpoint","is","found","and","restored",".","Otherwise","None","."]
code: def restore_or_initialize(self):
      """Restore items in `checkpoint` from the latest checkpoint file.
  
      This method will first try to restore from the most recent checkpoint in
      `directory`. If no checkpoints exist in `directory`, and `init_fn` is
      specified, this method will call `init_fn` to do customized
      initialization. This can be used to support initialization from pretrained
      models.
  
      Note that unlike `tf.train.Checkpoint.restore()`, this method doesn't return
      a load status object that users can run assertions on
      (e.g. assert_consumed()). Thus to run assertions, users should directly use
      `tf.train.Checkpoint.restore()` method.
  
      Returns:
        The restored checkpoint path if the lastest checkpoint is found and
        restored. Otherwise None.
      """
      # TODO(chienchunh): When AsyncCheckpoint is used, we may need to force to
      # sync until any ongoing async save is done. Otherwise, if this is the first
      # checkpoint and _latest_checkpoint has not been updated due to async write,
      # this would resort to init_fn instead of restoring from the checkpoin file.
      # This should be fixed once AsyncCheckpoint is integrated with the public
      # API so that we can rely on CheckpointOptions to tell whether we should
      # sync for AsyncCheckpoint.
      if self._latest_checkpoint is not None:
          self._checkpoint.restore(self._latest_checkpoint)
          if self._checkpoint_interval is not None:
              self._last_checkpoint_step = _evaluate(self._step_counter)
          return self._latest_checkpoint
  
      if self._init_fn is not None:
          self._init_fn()
          logging.info(
              "Customized initialization is done through the passed `init_fn`."
          )
      return None
  
imports: import collections
  import copy
  import os.path
  import re
  import time
  from google.protobuf import text_format
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.checkpoint import checkpoint_options
  from tensorflow.python.eager import context
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import training_util
  from tensorflow.python.training.checkpoint_state_pb2 import CheckpointState
  from tensorflow.python.util import compat
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 11 for calling the CheckpointManager obj's underlying member method code with example usage: obj.restore_or_initialize() and returns: None, self