def evaluate(model, graph, features, all_nodes_set, valid_set, test_set):
    """Evaluate the model on validation and test sets."""
    model.eval()

    dataloader = create_dataloader(
        graph,
        features,
        all_nodes_set,
        args.eval_batch_size,
        [-1],
        args.device,
        job="infer",
    )

    # Compute node embeddings for the entire graph.
    node_emb = model.inference(graph, features, dataloader, args.feature_device)
    results = []

    # Loop over both validation and test sets.
    for split in [valid_set, test_set]:
        # Unpack the item set.
        seeds = split._items[0].to(node_emb.device)
        labels = split._items[1].to(node_emb.device)
        indexes = split._items[2].to(node_emb.device)

        preds = compute_predictions(model, node_emb, seeds, indexes.device)
        # Compute MRR values for the current split.
        results.append(RetrievalMRR()(preds, labels, indexes))
    return results
Evaluate the model on validation and test sets.
examples/graphbolt/pyg/link_prediction.py