SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.00112 · NeurIPS · 2021

Transformer in Transformer

Kai Han, Chunjing Xu, Yunhe Wang, Enhua Wu, An Xiao, Jianyuan Guo

arXiv · PDF · Open in the Atlas

Code that ran

16 of 24 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (12 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 13 have no contract verdict; 1 failure of our instrument; 8 no recorded run), measured 2026-11-22; 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/2103.00112.json · badge: /api/ran/2103.00112.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
Rishit-dagli/Transformer-in-Transformer community
Papers with Code archive
5 ran · 0 no recorded run
NZ99/transformer_in_transformer_flax community
Papers with Code archive
4 ran · 3 no recorded run
huawei-noah/CV-Backbones marked official in Papers with Code
Papers with Code archive
4 ran · 1 no recorded run
lucidrains/transformer-in-transformer reimplementation (classifier label)
classifier basis: classifier_2025
3 ran · 4 no recorded run
FunctionStatusWhere it lives
AddPositionEmbs Ran
ran on a synthesized input · constructed an object; no result was computed
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("e7fd0617316574c2")
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, AddPositionEmbs: 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 jax
import jax.numpy as jnp
from jax.nn import initializers
from flax import linen as nn
from flax import struct

@struct.dataclass
class TNTConfig:
    """Global hyperparameters used to minimize obnoxious kwarg plumbing."""
    num_classes: int = 1000
    depth: int = 12
    image_size: int = 224
    patch_size: int = 16
    transformed_patch_size: int = 4
    inner_dim: int = 40
    inner_heads: int = 4
    inner_dim_head: int = 64
    inner_r: int = 4
    outer_dim: int = 640
    outer_heads: int = 10
    outer_dim_head: int = 64
    outer_r: int = 4
    dtype: type = jnp.float32
    kernel_init: callable = initializers.xavier_uniform()
    bias_init: callable = initializers.normal(stddev=1e-06)
    posemb_init: callable = initializers.normal(stddev=0.02)

class AddPositionEmbs(nn.Module):
    config: TNTConfig
    patch: bool

    @nn.compact
    def __call__(self, inputs):
        cfg = self.config
        assert inputs.ndim == 3, 'Number of dimensions should be 3, but it is: %d' % inputs.ndim
        if self.patch:
            pos_emb_shape = (1, inputs.shape[1], inputs.shape[2])
            pe = self.param('patch_pos_embedding', cfg.posemb_init, pos_emb_shape)
            return inputs + pe
        else:
            pos_emb_shape = (1, cfg.transformed_patch_size ** 2, inputs.shape[-1])
            pe = self.param('pixel_pos_embedding', cfg.posemb_init, pos_emb_shape)
            return inputs + pe

config = TNTConfig(
    num_classes=1000,
    depth=12,
    image_size=224,
    patch_size=16,
    transformed_patch_size=4,
    inner_dim=40,
    inner_heads=4,
    inner_dim_head=64,
    inner_r=4,
    outer_dim=640,
    outer_heads=10,
    outer_dim_head=64,
    outer_r=4,
    dtype=jnp.float32,
    kernel_init=initializers.xavier_uniform(),
    bias_init=initializers.normal(stddev=1e-06),
    posemb_init=initializers.normal(stddev=0.02)
)

ARGS = {
    "config": config,
    "patch": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AddPositionEmbs — 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 AddPositionEmbs 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
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
huawei-noah/CV-Backbones/tnt_pytorch/tnt.py
pointer only (licence: NONE) · get_code("aa47e20b1de49f21")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, huawei-noah/CV-Backbones when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Attention Ran
ran on a synthesized input · constructed an object; no result was computed
Rishit-dagli/Transformer-in-Transformer/tnt/tnt.py
code served (permissive licence) · get_code("ae43efde4f9bdb00")
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, Attention: 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 tensorflow as tf
import numpy as np

# Set seed for reproducibility
tf.random.set_seed(0)

# Create a small input tensor
# Shape: (batch=2, sequence_length=3, dim=4)
x = tf.constant(np.random.randn(2, 3, 4).astype(np.float32))

# Define ARGS dict with all parameters for Attention.__init__
ARGS = {
    'dim': 4,
    'heads': 2,
    'dim_head': 2,
    'dropout': 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attention — 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 Attention 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
Attention Ran
ran on a synthesized input
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("81188c67ea536d0b")
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, 5, 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
from torch import nn, einsum
from einops import rearrange, repeat

class Attention(nn.Module):

    def __init__(self, *, dim, heads=8, dim_head=64, dropout=0.0):
        super().__init__()
        inner_dim = heads * dim_head
        self.heads = heads
        self.scale = dim_head ** (-0.5)
        self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)
        self.to_out = nn.Sequential(nn.Linear(inner_dim, dim), nn.Dropout(dropout))

    def forward(self, x):
        b, n, d, h = (*x.shape, self.heads)
        q, k, v = self.to_qkv(x).chunk(3, dim=-1)
        q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> (b h) n d', h=h), (q, k, v))
        sim = einsum('b i d, b j d -> b i j', q, k) * self.scale
        attn = sim.softmax(dim=-1)
        out = einsum('b i j, b j d -> b i d', attn, v)
        out = rearrange(out, '(b h) n d -> b n (h d)', h=h)
        return self.to_out(out)


INIT_ARGS = {
    'dim': 4,
    'heads': 2,
    'dim_head': 3,
    'dropout': 0.1,
}

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

if __name__ == '__main__':
    attention = Attention(**INIT_ARGS)
    output = attention(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, 5, 4)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, 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, 5, 4) — shape (2, 5, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Block Ran
ran on a synthesized input · constructed an object; no result was computed
huawei-noah/CV-Backbones/tnt_pytorch/tnt.py
pointer only (licence: NONE) · get_code("0adf903cee3f68c1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, huawei-noah/CV-Backbones when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

FeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
Rishit-dagli/Transformer-in-Transformer/tnt/tnt.py
code served (permissive licence) · get_code("fa83b1a389d93eb9")
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, FeedForward: 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 tensorflow as tf

# The FeedForward layer takes:
# - dim: the input/output dimension
# - mult: multiplier for the hidden layer dimension (default 4)
# - dropout: dropout rate (default 0.0)

# Create small but distinct dimensions for testing
input_dim = 4
hidden_mult = 4
dropout_rate = 0.1

ARGS = {
    "dim": input_dim,
    "mult": hidden_mult,
    "dropout": dropout_rate,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type FeedForward — 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 FeedForward 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
MlpBlock Ran
ran on a synthesized input · constructed an object; no result was computed
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("0f86fae86e577e92")
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, MlpBlock: 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 jax
import jax.numpy as jnp
from jax.nn import initializers
from flax import linen as nn
from flax import struct

@struct.dataclass
class TNTConfig:
    """Global hyperparameters used to minimize obnoxious kwarg plumbing."""
    num_classes: int = 1000
    depth: int = 12
    image_size: int = 224
    patch_size: int = 16
    transformed_patch_size: int = 4
    inner_dim: int = 40
    inner_heads: int = 4
    inner_dim_head: int = 64
    inner_r: int = 4
    outer_dim: int = 640
    outer_heads: int = 10
    outer_dim_head: int = 64
    outer_r: int = 4
    dtype: jnp.dtype = jnp.float32
    kernel_init: callable = initializers.xavier_uniform()
    bias_init: callable = initializers.normal(stddev=1e-06)
    posemb_init: callable = initializers.normal(stddev=0.02)

class MlpBlock(nn.Module):
    config: TNTConfig
    inner: bool

    @nn.compact
    def __call__(self, inputs):
        cfg = self.config
        if self.inner:
            dim = cfg.inner_dim
            r = cfg.inner_r
        else:
            dim = cfg.outer_dim
            r = cfg.outer_r
        x = nn.Dense(dim * r, dtype=cfg.dtype, kernel_init=cfg.kernel_init, bias_init=cfg.bias_init)(inputs)
        x = nn.gelu(x)
        output = nn.Dense(dim, dtype=cfg.dtype, kernel_init=cfg.kernel_init, bias_init=cfg.bias_init)(x)
        return output

config = TNTConfig(
    num_classes=1000,
    depth=12,
    image_size=224,
    patch_size=16,
    transformed_patch_size=4,
    inner_dim=40,
    inner_heads=4,
    inner_dim_head=64,
    inner_r=4,
    outer_dim=640,
    outer_heads=10,
    outer_dim_head=64,
    outer_r=4,
    dtype=jnp.float32,
    kernel_init=initializers.xavier_uniform(),
    bias_init=initializers.normal(stddev=1e-06),
    posemb_init=initializers.normal(stddev=0.02)
)

ARGS = {
    "config": config,
    "inner": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MlpBlock — 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 MlpBlock 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
PatchEmbed Ran
ran on a synthesized input · constructed an object; no result was computed
huawei-noah/CV-Backbones/tnt_pytorch/tnt.py
pointer only (licence: NONE) · get_code("3ab31df137c0d6a7")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, huawei-noah/CV-Backbones when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

PreNorm Ran
ran on a synthesized input · constructed an object; no result was computed
Rishit-dagli/Transformer-in-Transformer/tnt/tnt.py
code served (permissive licence) · get_code("bc8ebba1f2a3f25c")
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, PreNorm: 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 tensorflow as tf
import numpy as np

# Create a simple function that the PreNorm layer will wrap
class SimpleFunction(tf.keras.layers.Layer):
    def __init__(self, dim):
        super(SimpleFunction, self).__init__()
        self.dense = tf.keras.layers.Dense(dim)
    
    def call(self, x, **kwargs):
        return self.dense(x)

# Set up the arguments
dim = 4
fn = SimpleFunction(dim=dim)

ARGS = {
    'dim': dim,
    'fn': fn
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PreNorm — 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 PreNorm 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
SE Ran
ran on a synthesized input · constructed an object; no result was computed
huawei-noah/CV-Backbones/tnt_pytorch/tnt.py
pointer only (licence: NONE) · get_code("3b5e96f71824e712")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, huawei-noah/CV-Backbones when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

TNT Ran
ran on a synthesized input · constructed an object; no result was computed
Rishit-dagli/Transformer-in-Transformer/tnt/tnt.py
code served (permissive licence) · get_code("3c37926a5a94b20c")
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, TNT: 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 tensorflow as tf
import numpy as np

# Set random seeds for reproducibility
tf.random.set_seed(0)
np.random.seed(0)

ARGS = {
    'image_size': 16,
    'patch_dim': 8,
    'pixel_dim': 6,
    'patch_size': 4,
    'pixel_size': 2,
    'depth': 1,
    'num_classes': 10,
    'heads': 2,
    'dim_head': 4,
    'ff_dropout': 0.1,
    'attn_dropout': 0.1,
    'unfold_args': (2, 2, 0),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TNT — 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 TNT 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
TNTConfig Ran
ran on a synthesized input · constructed an object; no result was computed
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("f10d48901b98d6a7")
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, TNTConfig: 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 jax
from jax import numpy as jnp
from jax.nn import initializers
from flax import struct

ARGS = {
    "num_classes": 1000,
    "depth": 12,
    "image_size": 224,
    "patch_size": 16,
    "transformed_patch_size": 4,
    "inner_dim": 40,
    "inner_heads": 4,
    "inner_dim_head": 64,
    "inner_r": 4,
    "outer_dim": 640,
    "outer_heads": 10,
    "outer_dim_head": 64,
    "outer_r": 4,
    "dtype": jnp.float32,
    "kernel_init": initializers.xavier_uniform(),
    "bias_init": initializers.normal(stddev=1e-06),
    "posemb_init": initializers.normal(stddev=0.02),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TNTConfig — 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 TNTConfig 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
TransformPatches Ran
ran on a synthesized input · constructed an object; no result was computed
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("4cb16ca8e61d759a")
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, TransformPatches: 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 jax
import jax.numpy as jnp
from jax.nn import initializers
from flax import linen as nn
from flax import struct
from einops import rearrange

@struct.dataclass
class TNTConfig:
    """Global hyperparameters used to minimize obnoxious kwarg plumbing."""
    num_classes: int = 1000
    depth: int = 12
    image_size: int = 224
    patch_size: int = 16
    transformed_patch_size: int = 4
    inner_dim: int = 40
    inner_heads: int = 4
    inner_dim_head: int = 64
    inner_r: int = 4
    outer_dim: int = 640
    outer_heads: int = 10
    outer_dim_head: int = 64
    outer_r: int = 4
    dtype: any = jnp.float32
    kernel_init: any = initializers.xavier_uniform()
    bias_init: any = initializers.normal(stddev=1e-06)
    posemb_init: any = initializers.normal(stddev=0.02)

class TransformPatches(nn.Module):
    config: TNTConfig

    @nn.compact
    def __call__(self, inputs):
        cfg = self.config
        x = rearrange(inputs, 'b (h p1) (w p2) c -> (b h w) p1 p2 c', p1=cfg.patch_size, p2=cfg.patch_size)
        x = rearrange(x, 'b (h h2) (w w2) c -> b (h w) (c h2 w2)', h2=cfg.transformed_patch_size, w2=cfg.transformed_patch_size)
        output = nn.Dense(cfg.inner_dim, dtype=cfg.dtype, kernel_init=cfg.kernel_init, bias_init=cfg.bias_init)(x)
        return output

config = TNTConfig(
    patch_size=16,
    transformed_patch_size=4,
    inner_dim=40,
    dtype=jnp.float32,
    kernel_init=initializers.xavier_uniform(),
    bias_init=initializers.normal(stddev=1e-06)
)

ARGS = {
    "config": config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, flax, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TransformPatches — 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 TransformPatches 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
divisible_by Ran
ran, violated the contract we drafted
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("f61d6e6e8177147a")
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 bool, 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
import numpy as np

torch.manual_seed(0)

# The function divisible_by takes two parameters: val and divisor
# It checks if val % divisor == 0
# Both should be integers or integer-like values

val = 10
divisor = 5

ARGS = {
    "val": val,
    "divisor": divisor,
}
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 bool, 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
get_elements_from_nested_list Ran
ran; our contract draft was wrong, not the code
Rishit-dagli/Transformer-in-Transformer/tnt/tnt.py
code served (permissive licence) · get_code("9a4efbdf001d9928")
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 list, ndim 1, dtype family int; 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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - get_elements_from_nested_list(l, new_l)
# - l: a nested list structure (can be None or contain lists/elements)
# - new_l: a list that collects flattened elements
# - The function recursively flattens a nested list structure

# Create test arguments
nested_list = [[1, 2], [3, [4, 5]], 6]
new_list = []

ARGS = {
    "l": nested_list,
    "new_l": new_list
}
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 list, ndim 1, dtype family int — a list 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
unfold_output_size Ran
ran, honoured the contract we drafted
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("cf4db82cbfb5407c")
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 int, ndim 0, dtype family int, 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
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# unfold_output_size(image_size, kernel_size, stride, padding)
# - image_size: int, the spatial dimension of input image
# - kernel_size: int, the size of the convolutional kernel
# - stride: int, the stride of the convolution
# - padding: int, the padding applied to the image
# All parameters are used in arithmetic operations

ARGS = {
    "image_size": 28,
    "kernel_size": 3,
    "stride": 1,
    "padding": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
Encoder Not yet run
unverified (harvested, no recorded run)
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("6a49d8dc0841e17c")
How it ran

no invocation recorded.

TNT Not yet run
unverified (harvested, no recorded run)
huawei-noah/CV-Backbones/tnt_pytorch/tnt.py
pointer only (licence: NONE) · get_code("5fc54ab39842a479")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, huawei-noah/CV-Backbones when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

TNT Not yet run
unverified (harvested, no recorded run)
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("19242d4759c5ee91")
How it ran

no invocation recorded.

TNTBlock Not yet run
unverified (harvested, no recorded run)
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("950a07c48a64e5ab")
How it ran

no invocation recorded.

TransformerInTransformer Not yet run
unverified (harvested, no recorded run)
NZ99/transformer_in_transformer_flax/transformer_in_transformer_flax/tnt.py
code served (permissive licence) · get_code("4b8fa19df5d3871a")
How it ran

no invocation recorded.

default Not yet run
unverified (harvested, no recorded run)
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("b506fc7ff0a3b8a4")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

divisible_by Not yet run
unverified (harvested, no recorded run)
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("65876fc080ac5567")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

exists Not yet run
unverified (harvested, no recorded run)
lucidrains/transformer-in-transformer/transformer_in_transformer/tnt.py
code served (permissive licence) · get_code("1e954f6d1f5902c2")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

Also present in other papers' code

Of 24 samples lifted from this paper's linked repositories, 24 carry a function identity and 0 do not. Of the 23 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 2 the same month, 2 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.

FunctionAlso present inEarliest-datedOthers named
exists
brick of this paper's assembly: helper
486 other papers
35 dated earlier, 5 the same month, 444 later, 2 undated · 78 only as an assembly brick
1603.08155 (2016-03)
Perceptual Losses for Real-Time Style Transfer and Super-Resolution
1611.07004 (2016-11)
Image-to-Image Translation with Conditional Adversarial Networks
1804.04637 (2018-04)
EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models
and 483 more not named here
default
brick of this paper's assembly: helper
163 other papers
14 dated earlier, 4 the same month, 144 later, 1 undated · 27 only as an assembly brick
1603.08155 (2016-03)
Perceptual Losses for Real-Time Style Transfer and Super-Resolution
1810.00825 (2018-10)
Set Transformer: A Framework for Attention-based Permutation-Invariant Neural Networks
1907.01470 (2019-07)
Augmenting Self-attention with Persistent Memory
and 160 more not named here

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-22.

Repositories linked to this paper

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

Abstract

Transformer is a new kind of neural architecture which encodes the input data as powerful features via the attention mechanism. Basically, the visual transformers first divide the input images into several local patches and then calculate both representations and their relationship. Since natural images are of high complexity with abundant detail and color information, the granularity of the patch dividing is not fine enough for excavating features of objects in different scales and locations. In this paper, we point out that the attention inside these local patches are also essential for building visual transformers with high performance and we explore a new architecture, namely, Transformer iN Transformer (TNT). Specifically, we regard the local patches (e.g., 16×16) as "visual sentences" and present to further divide them into smaller patches (e.g., 4×4) as "visual words". The attention of each word will be calculated with other words in the given visual sentence with negligible computational costs. Features of both words and sentences will be aggregated to enhance the representation ability. Experiments on several benchmarks demonstrate the effectiveness of the proposed TNT architecture, e.g., we achieve an 81.5% top-1 accuracy on the ImageNet, which is about 1.7% higher than that of the state-of-the-art visual transformer with similar computational cost.

For agents

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

get_harvested_code_for_paper("2103.00112")
get_code_for_paper("2103.00112")
have("2103.00112")

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

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

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

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

Connect an agent — have() is free.