parameters: (self, latest_save_path,
                                   meta_graph_suffix="meta")
docstring: Deletes old checkpoints if necessary.
  
      Always keep the last `max_to_keep` checkpoints.  If
      `keep_checkpoint_every_n_hours` was specified, keep an additional checkpoint
      every `N` hours. For example, if `N` is 0.5, an additional checkpoint is
      kept for every 0.5 hours of training; if `N` is 10, an additional
      checkpoint is kept for every 10 hours of training.
  
      Args:
        latest_save_path: Name including path of checkpoint file to save.
        meta_graph_suffix: Suffix for `MetaGraphDef` file. Defaults to 'meta'.
docstring_summary: Deletes old checkpoints if necessary.
docstring_tokens: Deletes old checkpoints if necessary .
function: def _MaybeDeleteOldCheckpoints(self, latest_save_path,
                                   meta_graph_suffix="meta"):
      """Deletes old checkpoints if necessary.
  
      Always keep the last `max_to_keep` checkpoints.  If
      `keep_checkpoint_every_n_hours` was specified, keep an additional checkpoint
      every `N` hours. For example, if `N` is 0.5, an additional checkpoint is
      kept for every 0.5 hours of training; if `N` is 10, an additional
      checkpoint is kept for every 10 hours of training.
  
      Args:
        latest_save_path: Name including path of checkpoint file to save.
        meta_graph_suffix: Suffix for `MetaGraphDef` file. Defaults to 'meta'.
      """
      if not self.saver_def.max_to_keep:
        return
      # Remove first from list if the same name was used before.
      for p in self._last_checkpoints:
        if latest_save_path == self._CheckpointFilename(p):
          self._last_checkpoints.remove(p)
      # Append new path to list
      self._last_checkpoints.append((latest_save_path, time.time()))
      # If more than max_to_keep, remove oldest.
      if len(self._last_checkpoints) > self.saver_def.max_to_keep:
        p = self._last_checkpoints.pop(0)
        # Do not delete the file if we keep_checkpoint_every_n_hours is set and we
        # have reached N hours of training.
        should_keep = p[1] > self._next_checkpoint_time
        if should_keep:
          self._next_checkpoint_time += (
              self.saver_def.keep_checkpoint_every_n_hours * 3600)
          return
        # Otherwise delete the files.
        for f in file_io.get_matching_files(
            self._CheckpointFilename(p)):
          try:
            file_io.delete_file(f)
            meta_graph_filename = self._MetaGraphFilename(
                f, meta_graph_suffix=meta_graph_suffix)
            if file_io.file_exists(meta_graph_filename):
              file_io.delete_file(meta_graph_filename)
          except Exception as e:  # pylint: disable=broad-except
            logging.warning("Ignoring: %s", str(e))
function_tokens: def _MaybeDeleteOldCheckpoints ( self , latest_save_path , meta_graph_suffix = "meta" ) : if not self . saver_def . max_to_keep : return # Remove first from list if the same name was used before. for p in self . _last_checkpoints : if latest_save_path == self . _CheckpointFilename ( p ) : self . _last_checkpoints . remove ( p ) # Append new path to list self . _last_checkpoints . append ( ( latest_save_path , time . time ( ) ) ) # If more than max_to_keep, remove oldest. if len ( self . _last_checkpoints ) > self . saver_def . max_to_keep : p = self . _last_checkpoints . pop ( 0 ) # Do not delete the file if we keep_checkpoint_every_n_hours is set and we # have reached N hours of training. should_keep = p [ 1 ] > self . _next_checkpoint_time if should_keep : self . _next_checkpoint_time += ( self . saver_def . keep_checkpoint_every_n_hours * 3600 ) return # Otherwise delete the files. for f in file_io . get_matching_files ( self . _CheckpointFilename ( p ) ) : try : file_io . delete_file ( f ) meta_graph_filename = self . _MetaGraphFilename ( f , meta_graph_suffix = meta_graph_suffix ) if file_io . file_exists ( meta_graph_filename ) : file_io . delete_file ( meta_graph_filename ) except Exception as e : # pylint: disable=broad-except logging . warning ( "Ignoring: %s" , str ( e ) )