def evaluate_wikikg90m(model, loader, mode, save_path):
    from ogb.lsc import WikiKG90MEvaluator
    evaluator = WikiKG90MEvaluator()
    model.eval()
    with paddle.no_grad():
        top_tens = []
        corr_idx = []
        for (h, r, t_idx, cand_t) in tqdm(loader):
            score = model.predict(h, r, cand_t)
            rank = paddle.argsort(score, axis=1, descending=True)
            top_tens.append(rank[:, :10].numpy())
            corr_idx.append(t_idx.numpy())
        t_pred_top10 = np.concatenate(top_tens, axis=0)
        t_correct_index = np.concatenate(corr_idx, axis=0)
        input_dict = {}
        if (mode == 'valid'):
            input_dict['h,r->t'] = {'t_pred_top10': t_pred_top10, 't_correct_index': t_correct_index}
            result = evaluator.eval(input_dict)
            logging.info(('-- %s results -------------' % mode))
            logging.info(' '.join(['{}: {}'.format(k, v) for (k, v) in result.items()]))
        else:
            input_dict['h,r->t'] = {'t_pred_top10': t_pred_top10}
            evaluator.save_test_submission(input_dict=input_dict, dir_path=save_path)
def evaluate_wikikg90m(model, loader, mode, save_path):
    from ogb.lsc import WikiKG90MEvaluator
    evaluator = WikiKG90MEvaluator()
    model.eval()
    with paddle.no_grad():
        top_tens = []
        corr_idx = []
        for (h, r, t_idx, cand_t) in tqdm(loader):
            score = model.predict(h, r, cand_t)
            rank = paddle.argsort(score, axis=1, descending=True)
            top_tens.append(rank[:, :10].numpy())
            corr_idx.append(t_idx.numpy())
        t_pred_top10 = np.concatenate(top_tens, axis=0)
        t_correct_index = np.concatenate(corr_idx, axis=0)
        input_dict = {}
        if (mode == 'valid'):
            input_dict['h,r->t'] = {'t_pred_top10': t_pred_top10, 't_correct_index': t_correct_index}
            result = evaluator.eval(input_dict)
            logging.info(('-- %s results -------------' % mode))
            logging.info(' '.join(['{}: {}'.format(k, v) for (k, v) in result.items()]))
        else:
            input_dict['h,r->t'] = {'t_pred_top10': t_pred_top10}
            evaluator.save_test_submission(input_dict=input_dict, dir_path=save_path)