import tensorflow as tf

                if var_shape == saved_shapes[key]:
                    var_list[key] = var
                    var_name = var.name[:var.name.index(':')]
                    msg.append('- restoring variable: {}'.format(var_name)
                               if var_name == key else
                               '- restoring variable {} from {}'.format(var_name, key))
                else:
                    msg.append(Color.yellow(
                        '- variable({}) with inconsistent shape: {}(graph) != {}(ckpt)'.format(
                            key, var_shape, saved_shapes[key])
                    ))
        if len(var_list) != 0:
            msg += ['- total variable count: {}'.format(len(var_list))]
            logger.info('\n'.join(msg))
            saver = tf.train.Saver(var_list, name='tk_restore')
            saver.restore(sess, self.restore_ckpt_file)
            return True
        else:
            logger.warn(Color.yellow('No vars need to restore from file: {}'.format(self.restore_ckpt_file)))
        return False

    def __str__(self):
        content = 'RESTORE_OPTIMISTIC: %s' \
                  '\nRESTORE_CHECKPOINT_FILE: %s' % (self._restore_optimistic, self.restore_ckpt_file)
        return content
