SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.05811 · NeurIPS · 2022

Deep Counterfactual Estimation with Categorical Background Variables

Edward De Brouwer

arXiv · PDF · Open in the Atlas

Code that ran

12 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 10 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2210.05811.json · badge: /api/ran/2210.05811.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
edebrouwer/cfqp canonical (classifier label)
classifier basis: classifier_2025
12 ran · 2 no recorded run
FunctionStatusWhere it lives
ConcatELU Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("b6fde1347f3c0487")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 3, 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
import torch.nn as nn
import torch.nn.functional as F

class ConcatELU(nn.Module):
    """
    Activation function that applies ELU in both direction (inverted and plain).
    Allows non-linearity while providing strong gradients for any input (important for final convolution)
    """

    def forward(self, x):
        return torch.cat([F.elu(x), F.elu(-x)], dim=1)


INIT_ARGS = {}

ARGS = {
    'x': torch.randn(2, 4, 3, 3)
}

if __name__ == '__main__':
    module = ConcatELU(**INIT_ARGS)
    output = module(**ARGS)
    print(f"Input shape: {ARGS['x'].shape}")
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 8, 3, 3) — shape (2, 8, 3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
ConditionalEmbedder Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("6c70686f770acba9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, 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
import torch.nn as nn
import numpy as np

# INIT_ARGS for ConditionalEmbedder.__init__
INIT_ARGS = {
    'embed_dim': 16,
    'in_channels': 2,
    'one_D': False,
    'conditional_len': 28
}

# ARGS for ConditionalEmbedder.forward
# X: image input with shape (batch_size, in_channels, conditional_len, conditional_len) for 2D
# T: treatment input with shape (batch_size,)
ARGS = {
    'X': torch.randn(3, 2, 28, 28),
    'T': torch.randn(3)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — 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 float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
CouplingLayer Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("376c28f71c667cda")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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

class CouplingLayer(nn.Module):

    def __init__(self, network, mask, c_in):
        """
        Coupling layer inside a normalizing flow.
        Inputs:
            network - A PyTorch nn.Module constituting the deep neural network for mu and sigma.
                      Output shape should be twice the channel size as the input.
            mask - Binary mask (0 or 1) where 0 denotes that the element should be transformed,
                   while 1 means the latent will be used as input to the NN.
            c_in - Number of input channels
        """
        super().__init__()
        self.network = network
        self.scaling_factor = nn.Parameter(torch.zeros(c_in))
        self.register_buffer('mask', mask)

    def forward(self, z, ldj, reverse=False, X=None, T=None):
        """
        Inputs:
            z - Latent input to the flow
            ldj - The current ldj of the previous flows.
                  The ldj of this layer will be added to this tensor.
            reverse - If True, we apply the inverse of the layer.
            orig_img (optional) - Only needed in VarDeq. Allows external
                                  input to condition the flow on (e.g. original image)
        """
        z_in = z * self.mask
        if X is None:
            nn_out = self.network(z_in)
        else:
            nn_out = self.network(z_in, X=X, T=T)
        s, t = nn_out.chunk(2, dim=1)
        s_fac = self.scaling_factor.exp().view(1, -1, 1, 1)
        s = torch.tanh(s / s_fac) * s_fac
        s = s * (1 - self.mask)
        t = t * (1 - self.mask)
        if not reverse:
            z = (z + t) * torch.exp(s)
            ldj += s.sum(dim=[1, 2, 3])
        else:
            z = z * torch.exp(-s) - t
            ldj -= s.sum(dim=[1, 2, 3])
        return (z, ldj)


class SimpleNetwork(nn.Module):
    def __init__(self, c_in, c_out):
        super().__init__()
        self.net = nn.Sequential(
            nn.Conv2d(c_in, 8, kernel_size=3, padding=1),
            nn.ReLU(),
            nn.Conv2d(8, c_out, kernel_size=3, padding=1)
        )
    
    def forward(self, x, X=None, T=None):
        return self.net(x)


c_in = 4
network = SimpleNetwork(c_in, 2 * c_in)
mask = torch.tensor([1, 0, 1, 0], dtype=torch.float32).view(1, 4, 1, 1)

INIT_ARGS = {
    'network': network,
    'mask': mask,
    'c_in': c_in
}

batch_size = 2
height = 3
width = 3
z = torch.randn(batch_size, c_in, height, width)
ldj = torch.zeros(batch_size)

ARGS = {
    'z': z,
    'ldj': ldj,
    'reverse': False,
    'X': None,
    'T': None
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Dense Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("94d4f204a05beb0f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 1) 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

class Dense(nn.Module):
    """A fully connected layer that reshapes outputs to feature maps."""

    def __init__(self, input_dim, output_dim, one_D):
        super().__init__()
        self.dense = nn.Linear(input_dim, output_dim)
        self.one_D = one_D

    def forward(self, x):
        if self.one_D:
            return self.dense(x)[..., None]
        else:
            return self.dense(x)[..., None, None]


INIT_ARGS = {
    'input_dim': 4,
    'output_dim': 3,
    'one_D': True,
}

ARGS = {
    'x': torch.randn(2, 4),
}

if __name__ == '__main__':
    model = Dense(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 3, 1) — shape (2, 3, 1) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Dequantization Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("fed58d977eb2e982")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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

INIT_ARGS = {
    'alpha': 1e-05,
    'quants': 256
}

ARGS = {
    'z': torch.randint(0, 256, (2, 3, 4, 5), dtype=torch.int32),
    'ldj': torch.zeros(2),
    'reverse': False,
    'X': None,
    'T': None
}

if __name__ == '__main__':
    from torch import nn
    import torch.nn.functional as F
    
    class Dequantization(nn.Module):

        def __init__(self, alpha=1e-05, quants=256):
            """
            Inputs:
                alpha - small constant that is used to scale the original input.
                        Prevents dealing with values very close to 0 and 1 when inverting the sigmoid
                quants - Number of possible discrete values (usually 256 for 8-bit image)
            """
            super().__init__()
            self.alpha = alpha
            self.quants = quants

        def forward(self, z, ldj, reverse=False, X=None, T=None):
            if not reverse:
                z, ldj = self.dequant(z, ldj)
                z, ldj = self.sigmoid(z, ldj, reverse=True)
            else:
                z, ldj = self.sigmoid(z, ldj, reverse=False)
                z = z * self.quants
                ldj += np.log(self.quants) * np.prod(z.shape[1:])
                z = torch.floor(z).clamp(min=0, max=self.quants - 1).to(torch.int32)
            return (z, ldj)

        def sigmoid(self, z, ldj, reverse=False):
            if not reverse:
                ldj += (-z - 2 * F.softplus(-z)).sum(dim=[1, 2, 3])
                z = torch.sigmoid(z)
            else:
                z = z * (1 - self.alpha) + 0.5 * self.alpha
                ldj += np.log(1 - self.alpha) * np.prod(z.shape[1:])
                ldj += (-torch.log(z) - torch.log(1 - z)).sum(dim=[1, 2, 3])
                z = torch.log(z) - torch.log(1 - z)
            return (z, ldj)

        def dequant(self, z, ldj):
            z = z.to(torch.float32)
            z = z + torch.rand_like(z).detach()
            z = z / self.quants
            ldj -= np.log(self.quants) * np.prod(z.shape[1:])
            return (z, ldj)
    
    model = Dequantization(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:", output[0].shape, output[1].shape)
    print("Success!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
GatedConv Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("38028e8d1730adef")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 3, 5) 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
import torch.nn.functional as F

class ConcatELU(nn.Module):
    """
    Activation function that applies ELU in both direction (inverted and plain).
    Allows non-linearity while providing strong gradients for any input (important for final convolution)
    """

    def forward(self, x):
        return torch.cat([F.elu(x), F.elu(-x)], dim=1)

class GatedConv(nn.Module):

    def __init__(self, c_in, c_hidden):
        """
        This module applies a two-layer convolutional ResNet block with input gate
        Inputs:
            c_in - Number of channels of the input
            c_hidden - Number of hidden dimensions we want to model (usually similar to c_in)
        """
        super().__init__()
        self.net = nn.Sequential(nn.Conv2d(c_in, c_hidden, kernel_size=3, padding=1), ConcatELU(), nn.Conv2d(2 * c_hidden, 2 * c_in, kernel_size=1))

    def forward(self, x):
        out = self.net(x)
        val, gate = out.chunk(2, dim=1)
        return x + val * torch.sigmoid(gate)


INIT_ARGS = {
    'c_in': 4,
    'c_hidden': 6,
}

ARGS = {
    'x': torch.randn(2, 4, 3, 5),
}

if __name__ == '__main__':
    model = GatedConv(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Input shape: {ARGS['x'].shape}")
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 3, 5) — shape (2, 4, 3, 5) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
ImageEmbedder Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("9223e49f435dc017")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 128) 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

class ImageEmbedder(nn.Module):

    def __init__(self, channels=[32, 64, 128, 256], in_channels=1, embed_dim=128, conditional_len=28, one_D=False):
        super().__init__()
        if one_D:
            self.conv = nn.Conv1d
        else:
            self.conv = nn.Conv2d
        out_len = conditional_len
        self.conv1 = self.conv(in_channels, channels[0], 3, stride=1, bias=False)
        out_len = out_len - 3 + 1
        self.gnorm1 = nn.GroupNorm(4, num_channels=channels[0])
        self.conv2 = self.conv(channels[0], channels[1], 3, stride=2, bias=False)
        out_len = int((out_len - 3) / 2 + 1)
        self.gnorm2 = nn.GroupNorm(32, num_channels=channels[1])
        self.conv3 = self.conv(channels[1], channels[2], 3, stride=2, bias=False)
        out_len = int((out_len - 3) / 2 + 1)
        self.gnorm3 = nn.GroupNorm(32, num_channels=channels[2])
        self.conv4 = self.conv(channels[2], channels[3], 3, stride=2, bias=False)
        out_len = int((out_len - 3) / 2 + 1)
        self.gnorm4 = nn.GroupNorm(32, num_channels=channels[3])
        if not one_D:
            out_len = out_len * out_len
        out_len *= channels[-1]
        self.out_fun = nn.Sequential(nn.Linear(int(out_len), 1024), nn.ReLU(), nn.Linear(1024, 512), nn.ReLU(), nn.Linear(512, embed_dim))
        self.act = lambda x: x * torch.sigmoid(x)

    def forward(self, x):
        h1 = self.conv1(x)
        h1 = self.gnorm1(h1)
        h1 = self.act(h1)
        h2 = self.conv2(h1)
        h2 = self.gnorm2(h2)
        h2 = self.act(h2)
        h3 = self.conv3(h2)
        h3 = self.gnorm3(h3)
        h3 = self.act(h3)
        h4 = self.conv4(h3)
        h4 = self.gnorm4(h4)
        h4 = self.act(h4)
        out = h4.view(h4.size(0), -1)
        out = self.out_fun(out)
        return out

INIT_ARGS = {
    'channels': [32, 64, 128, 256],
    'in_channels': 1,
    'embed_dim': 128,
    'conditional_len': 28,
    'one_D': False
}

ARGS = {
    'x': torch.randn(2, 1, 28, 28)
}

if __name__ == '__main__':
    model = ImageEmbedder(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: torch.Size([2, 128])")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 2, dtype family float, shape (2, 128) — shape (2, 128) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
LayerNormChannels Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("4c64baabf9213ee9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 3, 5) 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

INIT_ARGS = {
    'c_in': 4
}

ARGS = {
    'x': torch.randn(2, 4, 3, 5)
}

if __name__ == '__main__':
    model = nn.LayerNormChannels(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Input shape: {ARGS['x'].shape}")
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 3, 5) — shape (2, 4, 3, 5) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
SplitFlow Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("401b5c674fd422f5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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

class SplitFlow(nn.Module):

    def __init__(self):
        super().__init__()
        self.prior = torch.distributions.normal.Normal(loc=0.0, scale=1.0)

    def forward(self, z, ldj, reverse=False, X=None, T=None):
        if not reverse:
            z, z_split = z.chunk(2, dim=1)
            ldj += self.prior.log_prob(z_split).sum(dim=[1, 2, 3])
        else:
            z_split = self.prior.sample(sample_shape=z.shape).to(z.device)
            z = torch.cat([z, z_split], dim=1)
            ldj -= self.prior.log_prob(z_split).sum(dim=[1, 2, 3])
        return (z, ldj)


INIT_ARGS = {}

ARGS = {
    'z': torch.randn(2, 8, 3, 4),
    'ldj': torch.zeros(2),
    'reverse': False,
    'X': None,
    'T': None,
}

if __name__ == '__main__':
    model = SplitFlow(**INIT_ARGS)
    output = model(**ARGS)
    print("Forward pass output shapes:")
    print(f"  z shape: {output[0].shape}")
    print(f"  ldj shape: {output[1].shape}")
    
    ARGS['reverse'] = True
    output_reverse = model(**ARGS)
    print("Reverse pass output shapes:")
    print(f"  z shape: {output_reverse[0].shape}")
    print(f"  ldj shape: {output_reverse[1].shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
SqueezeFlow Ran
ran on a synthesized input
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("2fd221c99150b1ac")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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

class SqueezeFlow(nn.Module):

    def forward(self, z, ldj, reverse=False, X=None, T=None):
        B, C, H, W = z.shape
        if not reverse:
            z = z.reshape(B, C, H // 2, 2, W // 2, 2)
            z = z.permute(0, 1, 3, 5, 2, 4)
            z = z.reshape(B, 4 * C, H // 2, W // 2)
        else:
            z = z.reshape(B, C // 4, 2, 2, H, W)
            z = z.permute(0, 1, 4, 2, 5, 3)
            z = z.reshape(B, C // 4, H * 2, W * 2)
        return (z, ldj)

INIT_ARGS = {}

ARGS = {
    'z': torch.randn(2, 4, 4, 6),
    'ldj': torch.tensor(0.0),
    'reverse': False,
    'X': None,
    'T': None
}

model = SqueezeFlow(**INIT_ARGS)
output = model(**ARGS)
print("Forward pass output shape:", output[0].shape)
print("LDJ output:", output[1])

ARGS_reverse = {
    'z': torch.randn(2, 16, 2, 3),
    'ldj': torch.tensor(0.0),
    'reverse': True,
    'X': None,
    'T': None
}

output_reverse = model(**ARGS_reverse)
print("Reverse pass output shape:", output_reverse[0].shape)
print("LDJ output:", output_reverse[1])
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
create_channel_mask Ran
ran, honoured the contract we drafted
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("b7eb9187d2bf923b")
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) and returned Tensor, ndim 4, dtype family float, shape (1, 8, 1, 1) 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)

ARGS = {
    "c_in": 8,
    "invert": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 (1, 8, 1, 1) — shape (1, 8, 1, 1) 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
create_checkerboard_mask Ran
ran, honoured the contract we drafted
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("60a6d4fde58fae8f")
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) and returned Tensor, ndim 4, dtype family float, shape (1, 1, 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)

ARGS = {
    "h": 4,
    "w": 3,
    "invert": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 (1, 1, 4, 3) — shape (1, 1, 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
DeepSCM Not yet run
unverified (harvested, no recorded run)
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("61ed57e4cf40e7ed")
How it ran

no invocation recorded.

GatedConvNet Not yet run
unverified (harvested, no recorded run)
edebrouwer/cfqp/condgen/models/deepscm.py
code served (permissive licence) · get_code("b63ac09163dbabc2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 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 14 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-23.

Repositories linked to this paper

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

Abstract

Referred to as the third rung of the causal inference ladder, counterfactual queries typically ask the "What if ?" question retrospectively. The standard approach to estimate counterfactuals resides in using a structural equation model that accurately reflects the underlying data generating process. However, such models are seldom available in practice and one usually wishes to infer them from observational data alone. Unfortunately, the correct structural equation model is in general not identifiable from the observed factual distribution. Nevertheless, in this work, we show that under the assumption that the main latent contributors to the treatment responses are categorical, the counterfactuals can be still reliably predicted. Building upon this assumption, we introduce CounterFactual Query Prediction (CFQP), a novel method to infer counterfactuals from continuous observations when the background variables are categorical. We show that our method significantly outperforms previously available deep-learning-based counterfactual methods, both theoretically and empirically on time series and image data. Our code is available at https://github.com/edebrouwer/cfqp.

For agents

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

get_harvested_code_for_paper("2210.05811")
get_code_for_paper("2210.05811")
have("2210.05811")

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

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

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

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

Connect an agent — have() is free.