SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.19321 · NeurIPS · 2023

D4Explainer: In-Distribution GNN Explanations via Discrete Denoising Diffusion

Rex Ying, Shirley Wu, Jialin Chen, Abhijit Gupta

arXiv · PDF · Open in the Atlas

Code that ran

15 of 21 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 10 failures of our instrument; 6 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.19321.json · badge: /api/ran/2310.19321.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
graph-and-geometric-learning/d4explainer marked official in Papers with Code
Papers with Code archive
15 ran · 6 no recorded run
FunctionStatusWhere it lives
FeatureExtractor Ran
ran on a synthesized input · constructed an object; no result was computed
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("876af85f8e3ffb2b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, FeatureExtractor: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "in_features": 5,
    "out_features": 3,
    "spectral_norm": lambda x: x,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type FeatureExtractor — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a FeatureExtractor output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Powerful Ran
ran on a synthesized input · constructed an object; no result was computed
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("224789a60fc208a5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Powerful: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class ArgsConfig:
    def __init__(self):
        self.cat_output = True
        self.normalization = "instance"
        self.layers_per_conv = 2
        self.simplified = False
        self.dropout = 0.1
        self.residual = True
        self.noise_mlp = False
        self.device = "cpu"
        self.num_layers = 3
        self.n_hidden = 8
        self.feature_in = 4
        self.num_classes = 2

ARGS = {
    "args": ArgsConfig(),
    "spectral_norm": lambda x: x,
    "project_first": False,
    "node_out": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Powerful — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Powerful output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PowerfulLayer Ran
ran on a synthesized input · constructed an object; no result was computed
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("55f7243fa5953c0d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PowerfulLayer: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple spectral_norm function that acts as identity
def identity_spectral_norm(x):
    return x

# Create test data
batch_size = 2
N = 4  # spatial dimension
in_feat = 5
out_feat = 3
num_layers = 2

# Create input tensor: batch x N x N x in_feat
x = torch.randn(batch_size, N, N, in_feat)

# Create mask tensor: batch x N x N x 1
mask = torch.ones(batch_size, N, N, 1)

ARGS = {
    "in_feat": in_feat,
    "out_feat": out_feat,
    "num_layers": num_layers,
    "spectral_norm": identity_spectral_norm
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PowerfulLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PowerfulLayer output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
discretenoise_single Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("6dfdb2f6de8a0f00")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 4, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small test tensors
batch_size = 2
num_nodes = 4

# train_adj_b: [batch_size, N, N] - batch of adjacency matrices
# Values should be between 0 and 1 for bernoulli sampling
train_adj_b = torch.rand(batch_size, num_nodes, num_nodes)

# node_flags: [batch_size, N] - flags indicating which nodes exist
# Binary flags: 1 if node exists, 0 if it doesn't
node_flags = torch.tensor([[1, 1, 1, 0],
                           [1, 1, 0, 0]], dtype=torch.float32)

# sigma: noise level (scalar float)
sigma = 0.5

# device: CPU device
device = 'cpu'

ARGS = {
    'train_adj_b': train_adj_b,
    'node_flags': node_flags,
    'sigma': sigma,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 4, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gen_full Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("a4424d0337fb23aa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch_geometric.utils import degree

torch.manual_seed(0)

# Create a batch tensor that assigns nodes to graphs
# For a small example: 6 nodes total, 2 graphs
# Graph 0: nodes 0,1,2 (3 nodes)
# Graph 1: nodes 3,4,5 (3 nodes)
batch = torch.tensor([0, 0, 0, 1, 1, 1], dtype=torch.long)

# Create a mask tensor [bsz=2, N=3, N=3]
# This represents adjacency information for each graph
# Graph 0 mask: some edges between its 3 nodes
# Graph 1 mask: some edges between its 3 nodes
mask = torch.zeros(2, 3, 3, dtype=torch.long)
mask[0, 0, 1] = 1  # edge in graph 0
mask[0, 1, 2] = 1  # edge in graph 0
mask[1, 0, 2] = 1  # edge in graph 1
mask[1, 1, 0] = 1  # edge in graph 1

ARGS = {
    "batch": batch,
    "mask": mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gen_list_of_data_single Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("2c0b5b94f76fedb0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Small stand-in class for args
class Args:
    def __init__(self):
        self.device = 'cpu'

args = Args()

# Define parameters for gen_list_of_data_single
batch_size = 2
N = 4  # number of nodes
F_in = 3  # number of features

# Create small tensors
train_x_b = torch.randn(batch_size, N, F_in)
train_adj_b = torch.randint(0, 2, (batch_size, N, N)).float()
train_adj_b = (train_adj_b + train_adj_b.transpose(-1, -2)) / 2  # make symmetric
train_node_flag_b = torch.ones(batch_size, N)
sigma_list = [0.1, 0.5]

ARGS = {
    'train_x_b': train_x_b,
    'train_adj_b': train_adj_b,
    'train_node_flag_b': train_node_flag_b,
    'sigma_list': sigma_list,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_mask Ran
ran, honoured the contract we drafted
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("d59e27b5fae8a2be")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family int, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# node_flags: [bsz, N] tensor with flags for existence of nodes
# We'll create a small batch of size 2 with 4 nodes each
node_flags = torch.tensor([
    [1.0, 1.0, 0.0, 1.0],
    [1.0, 0.0, 1.0, 1.0]
], dtype=torch.float32)

ARGS = {
    "node_flags": node_flags
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family int, shape (2, 4, 4) — shape (2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gnn_pred Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("c450ff9a010d27ad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockGNNModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def get_node_pred_subgraph(self, x, edge_index, mapping):
        # Returns output probabilities and something else
        output = self.linear(x)
        output_prob = torch.softmax(output, dim=-1)
        return output_prob, None
    
    def get_pred(self, x, edge_index, batch):
        # Returns output probabilities and something else
        output = self.linear(x)
        output_prob = torch.softmax(output, dim=-1)
        return output_prob, None

class MockGraph:
    def __init__(self, num_nodes=5, num_edges=6, use_batch=False):
        self.x = torch.randn(num_nodes, 4)
        self.edge_index = torch.randint(0, num_nodes, (2, num_edges))
        self.mapping = torch.arange(num_nodes)
        if use_batch:
            self.batch = torch.tensor([0, 0, 0, 1, 1])

class MockDataset:
    def __init__(self):
        self.num_classes = 3

# Create instances for node classification task
graph_batch_nc = MockGraph(num_nodes=5, num_edges=6, use_batch=False)
graph_batch_sub_nc = MockGraph(num_nodes=3, num_edges=4, use_batch=False)

# Create instances for graph classification task
graph_batch_gc = MockGraph(num_nodes=5, num_edges=6, use_batch=True)
graph_batch_sub_gc = MockGraph(num_nodes=3, num_edges=4, use_batch=True)

gnn_model = MockGNNModel()
ds = MockDataset()

# For node classification task
ARGS = {
    "graph_batch": graph_batch_nc,
    "graph_batch_sub": graph_batch_sub_nc,
    "gnn_model": gnn_model,
    "ds": ds,
    "task": "nc"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
graph2tensor Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("bad5406d867eff25")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch_geometric.data import Data, Batch

torch.manual_seed(0)

# Create two small graphs
# Graph 1: 3 nodes, 2 features
x1 = torch.randn(3, 2)
edge_index1 = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]])

# Graph 2: 2 nodes, 2 features
x2 = torch.randn(2, 2)
edge_index2 = torch.tensor([[0, 1], [1, 0]])

# Create Data objects
data1 = Data(x=x1, edge_index=edge_index1)
data2 = Data(x=x2, edge_index=edge_index2)

# Create batch
graph = Batch.from_data_list([data1, data2])

device = 'cpu'

ARGS = {
    'graph': graph,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
loss_cf_exp Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("6a78eeb85c913ca8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal GNN model that has the required methods
class MinimalGNNModel(nn.Module):
    def __init__(self, input_dim=4, hidden_dim=8, output_dim=3):
        super().__init__()
        self.lin1 = nn.Linear(input_dim, hidden_dim)
        self.lin2 = nn.Linear(hidden_dim, output_dim)
    
    def get_pred_explain(self, x, edge_index, edge_mask, mapping=None, batch=None):
        # Returns (output_prob, output_repr)
        # output_prob: log probabilities [batch_size, num_classes]
        # output_repr: representations [batch_size, num_classes]
        batch_size = x.size(0)
        repr_out = self.lin1(x)
        logits = self.lin2(repr_out)
        log_probs = torch.nn.functional.log_softmax(logits, dim=-1)
        return log_probs, logits

# Create minimal graph batch object
class GraphBatch:
    def __init__(self, x, edge_index, mapping=None, batch=None):
        self.x = x
        self.edge_index = edge_index
        self.mapping = mapping
        self.batch = batch

# Setup tensor dimensions
batch_size = 2
num_nodes = 2
num_features = 4
num_classes = 3
num_edges = 3

# Create node features
x = torch.randn(num_nodes, num_features)

# Create edge index
edge_index = torch.LongTensor([[0, 1, 0], [1, 0, 1]])

# Create graph batch
graph_batch = GraphBatch(
    x=x,
    edge_index=edge_index,
    mapping=torch.LongTensor([0, 1]),
    batch=torch.LongTensor([0, 1])
)

# Create GNN model
gnn_model = MinimalGNNModel(input_dim=num_features, hidden_dim=8, output_dim=num_classes)

# Create score list - one score per edge
score = [torch.randn(num_edges, 1) for _ in range(batch_size)]

# Create predicted labels
y_pred = torch.LongTensor([0, 1])

# Create explanation labels (will be overwritten in function)
y_exp = torch.LongTensor([0, 1])

# Create full edge index
full_edge = edge_index

# Create mask for edges [num_edges, 1]
mask = torch.ones(num_edges, 1)

# Create dataset (placeholder)
ds = None

ARGS = {
    'gnn_model': gnn_model,
    'graph_batch': graph_batch,
    'score': score,
    'y_pred': y_pred,
    'y_exp': y_exp,
    'full_edge': full_edge,
    'mask': mask,
    'ds': ds,
    'task': 'nc'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
loss_func_bce Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("63fed087bd0312f9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Parameters for loss_func_bce
device = torch.device("cpu")
num_node = 4
bsz = 2
sigma_list = [0.5, 1.5]
num_samples = len(sigma_list) * bsz

# score_list: [len(sigma_list)*bsz, N, N]
score_list = torch.randn(num_samples, num_node, num_node, device=device)

# groundtruth: [len(sigma_list)*bsz, N, N]
groundtruth = torch.randint(0, 2, (num_samples, num_node, num_node), dtype=torch.float32, device=device)

# mask: [len(sigma_list)*bsz, N, N]
mask = torch.ones(num_samples, num_node, num_node, device=device)

# sparsity_level: scalar
sparsity_level = 2.0

ARGS = {
    "score_list": score_list,
    "groundtruth": groundtruth,
    "sigma_list": sigma_list,
    "mask": mask,
    "device": device,
    "sparsity_level": sparsity_level,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mask_adjs Ran
ran, honoured the contract we drafted
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("fdd19f4eeaaf2335")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Case 1: 3D adjacency matrix (B x N x N)
adjs_3d = torch.randn(2, 4, 4)

# Case 2: 4D adjacency matrix (B x C x N x N)
adjs_4d = torch.randn(2, 3, 4, 4)

# Node flags indicating which nodes are valid (B x N)
node_flags = torch.randint(0, 2, (2, 4)).float()

# Test with 3D case
ARGS = {
    "adjs": adjs_3d,
    "node_flags": node_flags
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
masked_instance_norm2D Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("e0e84c89f30caaad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 4, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create x tensor: [batch_size=2, num_objects=4, num_objects=4, features=3]
x = torch.randn(2, 4, 4, 3)

# Create mask tensor: [batch_size=2, num_objects=4, num_objects=4, 1]
# Use values between 0 and 1 to represent which elements are valid
mask = torch.randint(0, 2, (2, 4, 4, 1)).float()

# Ensure at least one batch has some non-zero mask values
mask[0, :, :, :] = 1.0

eps = 1e-05

ARGS = {
    "x": x,
    "mask": mask,
    "eps": eps
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 4, 4, 3) — shape (2, 4, 4, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sparsity Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("270d02a1f79ddaf1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# score: [bsz, N, N, 1] - list of tensors
bsz = 2
N = 4
score = [
    torch.randn(N, N, 1),
    torch.randn(N, N, 1),
]

# groundtruth: [bsz, N, N]
groundtruth = torch.randint(0, 2, (bsz, N, N)).float()

# mask: [bsz, N, N]
mask = torch.ones(bsz, N, N)

# threshold: float
threshold = 0.5

ARGS = {
    "score": score,
    "groundtruth": groundtruth,
    "mask": mask,
    "threshold": threshold,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tensor2graph Ran
ran; our contract draft was wrong, not the code
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("c88f152103fd6b98")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Data. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch_geometric.data import Data, Batch

torch.manual_seed(0)

# Create a small graph batch
# We need graph_batch to have a .batch attribute and be cloneable
num_nodes_graph1 = 3
num_nodes_graph2 = 2
total_nodes = num_nodes_graph1 + num_nodes_graph2

# Create node features
x = torch.randn(total_nodes, 4)

# Create edge index for the graph batch
edge_index = torch.tensor([[0, 1, 1, 2, 3, 4], 
                           [1, 0, 2, 1, 4, 3]], dtype=torch.long)

# Create batch assignment (which graph each node belongs to)
batch_assignment = torch.tensor([0, 0, 0, 1, 1], dtype=torch.long)

# Create the graph batch
graph_batch = Data(x=x, edge_index=edge_index)
graph_batch.batch = batch_assignment

# Parameters for tensor2graph
bsz = 2  # batch size
N = 5    # max nodes (total_nodes in this case)

# score: [bsz, N, N, 1] - list of score tensors
# The function stacks them and squeezes the last dimension
score = [torch.randn(bsz, N, N, 1) for _ in range(3)]

# mask_adj: [bsz, N, N] - adjacency mask
mask_adj = torch.ones(bsz, N, N, dtype=torch.long)
# Set some positions to 0 to create a valid mask
mask_adj[0, 4, :] = 0
mask_adj[0, :, 4] = 0
mask_adj[1, 3, :] = 0
mask_adj[1, 4, :] = 0
mask_adj[1, :, 3] = 0
mask_adj[1, :, 4] = 0

# threshold parameter
threshold = 0.5

ARGS = {
    'graph_batch': graph_batch,
    'score': score,
    'mask_adj': mask_adj,
    'threshold': threshold
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Data — a Data output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
DiffExplainer Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("c14f6a99b3a0f100")
How it ran

no invocation recorded.

Explainer Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("4e59a98458bb3be0")
How it ran

no invocation recorded.

e_map_mutag Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("910c9cb3a669f5b0")
How it ran

no invocation recorded.

graph_to_mol Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("ffae4597c717f872")
How it ran

no invocation recorded.

model_save Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("52dde03888435cc5")
How it ran

no invocation recorded.

x_map_mutag Not yet run
unverified (harvested, no recorded run)
graph-and-geometric-learning/d4explainer/explainers/diff_explainer.py
code served (permissive licence) · get_code("8e3e1e254a4e2c8a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 21 samples lifted from this paper's linked repositories, 21 carry a function identity and 0 do not. Of the 21 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 21 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The widespread deployment of Graph Neural Networks (GNNs) sparks significant interest in their explainability, which plays a vital role in model auditing and ensuring trustworthy graph learning. The objective of GNN explainability is to discern the underlying graph structures that have the most significant impact on model predictions. Ensuring that explanations generated are reliable necessitates consideration of the in-distribution property, particularly due to the vulnerability of GNNs to out-of-distribution data. Unfortunately, prevailing explainability methods tend to constrain the generated explanations to the structure of the original graph, thereby downplaying the significance of the in-distribution property and resulting in explanations that lack reliability. To address these challenges, we propose D4Explainer, a novel approach that provides in-distribution GNN explanations for both counterfactual and model-level explanation scenarios. The proposed D4Explainer incorporates generative graph distribution learning into the optimization objective, which accomplishes two goals: 1) generate a collection of diverse counterfactual graphs that conform to the in-distribution property for a given instance, and 2) identify the most discriminative graph patterns that contribute to a specific class prediction, thus serving as model-level explanations. It is worth mentioning that D4Explainer is the first unified framework that combines both counterfactual and model-level explanations. Empirical evaluations conducted on synthetic and real-world datasets provide compelling evidence of the state-ofthe-art performance achieved by D4Explainer in terms of explanation accuracy, faithfulness, diversity, and robustness. 1

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.19321")
get_code_for_paper("2310.19321")
have("2310.19321")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.19321.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.19321.svg)](https://syntology.ai/paper/2310.19321)

Connect an agent — have() is free.