'Builds the TF graph and loads the checkpoint.
If the graph has already been initialized, this is a no-op.
Raises:
SequenceGeneratorException: If the checkpoint cannot be found.'

def initialize(self):

    if self._initialized:
        return
    if (self._checkpoint is not None):
        if (not _checkpoint_file_exists(self._checkpoint)):
            raise SequenceGeneratorException(('Checkpoint    path    does    not    exist:    %s' % self._checkpoint))
        checkpoint_file = self._checkpoint
        if tf.gfile.IsDirectory(checkpoint_file):
            checkpoint_file = tf.train.latest_checkpoint(checkpoint_file)
        if (checkpoint_file is None):
            raise SequenceGeneratorException(('No    checkpoint    file    found    in    directory:    %s' % self._checkpoint))
        if ((not _checkpoint_file_exists(self._checkpoint)) or tf.gfile.IsDirectory(checkpoint_file)):
            raise SequenceGeneratorException(('Checkpoint    path    is    not    a    file:    %s    (supplied    path:    %s)' % (checkpoint_file, self._checkpoint)))
        self._model.initialize_with_checkpoint(checkpoint_file)
    else:
        tempdir = None
        try:
            tempdir = tempfile.mkdtemp()
            checkpoint_filename = os.path.join(tempdir, 'model.ckpt')
            with tf.gfile.Open(checkpoint_filename, 'wb') as f:
                f.write(self._bundle.checkpoint_file[0])
            metagraph_filename = os.path.join(tempdir, 'model.ckpt.meta')
            with tf.gfile.Open(metagraph_filename, 'wb') as f:
                f.write(self._bundle.metagraph_file)
            self._model.initialize_with_checkpoint_and_metagraph(checkpoint_filename, metagraph_filename)
        finally:
            if (tempdir is not None):
                tf.gfile.DeleteRecursively(tempdir)
    self._initialized = True
