'Creates a function that restores a model from checkpoint.
Args:
checkpoint_path: Checkpoint file or a directory containing a checkpoint
file.
saver: Saver for restoring variables from the checkpoint file.
Returns:
restore_fn: A function such that restore_fn(sess) loads model variables
from the checkpoint file.
Raises:
ValueError: If checkpoint_path does not refer to a checkpoint file or a
directory containing a checkpoint file.'

def _create_restore_fn(self, checkpoint_path, saver):

    if tf.gfile.IsDirectory(checkpoint_path):
        checkpoint_path = tf.train.latest_checkpoint(checkpoint_path)
        if (not checkpoint_path):
            raise ValueError(('No    checkpoint    file    found    in:    %s' % checkpoint_path))
    def _restore_fn(sess):
        tf.logging.info('Loading    model    from    checkpoint:    %s', checkpoint_path)
        saver.restore(sess, checkpoint_path)
        tf.logging.info('Successfully    loaded    checkpoint:    %s', os.path.basename(checkpoint_path))
    return _restore_fn
