SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.10569 · NeurIPS · 2024

Learning to Merge Tokens via Decoupled Embedding for Efficient Vision Transformers

Dong Lee, Seunghoon Hong

arXiv · PDF · Open in the Atlas

Code that ran

28 of 34 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 24 failures of our instrument; 6 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/2412.10569.json · badge: /api/ran/2412.10569.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
huggingface/pytorch-image-models canonical (classifier label)
classifier basis: census
21 ran · 4 no recorded run
rstrudel/segmenter canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
movinghoon/dtem canonical (classifier label)
classifier basis: classifier_2025
2 ran · 2 no recorded run
FunctionStatusWhere it lives
DTEMLinear Ran
ran on a synthesized input · constructed an object; no result was computed
movinghoon/dtem/dtem/dtem.py
pointer only (licence: NONE) · get_code("312fe94ea2ff8a1d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, movinghoon/dtem 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.

accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
rstrudel/segmenter/segm/metrics.py
code served (permissive licence) · get_code("2cc3699f9a695af9")
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 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

torch.manual_seed(0)

# Construct arguments for the accuracy function
# The function expects:
# - output: tensor of shape (batch_size, num_classes) with logits/scores
# - target: tensor of shape (batch_size,) with class indices
# - topk: tuple of integers specifying which top-k accuracies to compute

batch_size = 2
num_classes = 4

# output: logits tensor of shape (batch_size, num_classes)
output = torch.randn(batch_size, num_classes)

# target: ground truth class indices of shape (batch_size,)
target = torch.tensor([0, 2])

# topk: tuple of k values to compute accuracy for
topk = (1, 2)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk
}
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 list, ndim 2, dtype family float — 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
adapt_model_from_string Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_prune.py
code served (permissive licence) · get_code("c6172c0e559329a4")
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 MinimalModel. 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
from timm.layers import Conv2dSame, BatchNormAct2d, Linear

torch.manual_seed(0)

# Build a minimal model with the expected structure
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Sequential(
            Conv2dSame(in_channels=3, out_channels=16, kernel_size=3),
            BatchNormAct2d(16),
        )
        self.layer2 = nn.Sequential(
            nn.Conv2d(in_channels=16, out_channels=32, kernel_size=3),
            nn.BatchNorm2d(32),
        )
        self.fc = Linear(in_features=32, out_features=10)
        self.num_features = 32

parent_module = MinimalModel()

# Create a model_string that specifies pruned dimensions
# Format: "layer.weight:[shape]***layer.weight:[shape]***..."
model_string = (
    "layer1.0.weight:[8,3,3,3]***"
    "layer1.1.weight:[8]***"
    "layer2.0.weight:[16,8,3,3]***"
    "layer2.1.weight:[16]***"
    "fc.weight:[10,16]"
)

ARGS = {
    "parent_module": parent_module,
    "model_string": model_string,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MinimalModel — a MinimalModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MinimalModel 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
bipartite_soft_matching Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
movinghoon/dtem/dtem/dtem.py
pointer only (licence: NONE) · get_code("a7408ebd9837b099")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, movinghoon/dtem 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.

blend_im Ran
ran; our contract draft was wrong, not the code
rstrudel/segmenter/segm/eval/miou.py
code served (permissive licence) · get_code("17b43c5865bd0c55")
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 ndarray, ndim 3, dtype family int, shape (4, 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 numpy as np
from PIL import Image

# Create sample image data
# im and seg should be numpy arrays that can be converted to PIL Images
# For blend_im, both need to be compatible with Image.fromarray()
# Typical image arrays are uint8 with shape (H, W) or (H, W, 3) or (H, W, 4)

# Create a small 4x3 RGB image (height=4, width=3, channels=3)
im = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# Create a small 4x3 RGB segmentation map (same shape for blending)
seg = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# alpha is a float between 0 and 1
alpha = 0.5

ARGS = {
    'im': im,
    'seg': seg,
    'alpha': alpha
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (4, 3, 3) — shape (4, 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: none by the harness; any seed is in the setup block
check_cached_file Ran
ran, violated the contract we drafted
huggingface/pytorch-image-models/timm/models/_hub.py
code served (permissive licence) · get_code("4d444e5247299816")
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 os
import tempfile
from pathlib import Path

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()

# Create a test file with hash prefix in filename
test_filename = "model-a1b2c3d4e5f6.pth"
test_file_path = os.path.join(temp_dir, test_filename)

# Create the file with some content
with open(test_file_path, 'wb') as f:
    f.write(b"test model data")

# Calculate the actual hash of the file content
import hashlib
with open(test_file_path, 'rb') as f:
    actual_hash = hashlib.sha256(f.read()).hexdigest()

# Use the actual hash prefix in the filename
hash_prefix = actual_hash[:8]
correct_filename = f"model-{hash_prefix}.pth"
correct_file_path = os.path.join(temp_dir, correct_filename)

# Rename the file to have correct hash
if test_file_path != correct_file_path:
    os.rename(test_file_path, correct_file_path)

# Test case 1: URL as string
url_string = "https://example.com/path/to/model.pth"

# Test case 2: URL as tuple with (url, filename)
url_tuple = ("https://example.com/model", correct_filename)

ARGS = {
    "url": url_string,
    "check_hash": True,
    "cache_dir": temp_dir,
}
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 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
checkpoint_filter_fn Ran
ran; our contract draft was wrong, not the code
rstrudel/segmenter/segm/model/utils.py
code served (permissive licence) · get_code("fa761055851f5f0c")
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 dict. 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 math

torch.manual_seed(0)

# Create a minimal model that has the attributes used in checkpoint_filter_fn
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.patch_size = 16
        self.patch_embed = nn.Module()
        self.patch_embed.image_size = (224, 224)
        # pos_embed shape: [1, num_patches + num_extra_tokens, embed_dim]
        # For 224x224 with patch_size 16: (224/16)^2 = 196 patches
        # With 1 class token: 197 total tokens
        self.pos_embed = nn.Parameter(torch.randn(1, 197, 768))

model = MinimalModel()

# Create a state_dict that will trigger the pos_embed resizing
# Old grid was 14x14 (196 patches + 1 class token = 197)
# New grid should be 14x14 as well (224/16 = 14)
state_dict = {
    'pos_embed': torch.randn(1, 197, 768),
    'patch_embed.proj.weight': torch.randn(768, 3, 16, 16),
    'patch_embed.proj.bias': torch.randn(768),
    'cls_token': torch.randn(1, 1, 768),
}

ARGS = {
    'state_dict': state_dict,
    'model': model,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
clean_state_dict Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_helpers.py
code served (permissive licence) · get_code("930f19095abcbbf7")
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 dict. 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)

# The function clean_state_dict takes a state_dict (Dict[str, Any])
# It iterates through key-value pairs and removes prefixes from keys
# The values can be any type (typically tensors in state dicts)

state_dict = {
    'module.layer1.weight': torch.randn(4, 3),
    'module.layer1.bias': torch.randn(4),
    '_orig_mod.layer2.weight': torch.randn(5, 4),
    'layer3.weight': torch.randn(3, 5),
    'module.batch_norm.running_mean': torch.randn(4),
    '_orig_mod.batch_norm.running_var': torch.randn(4),
}

ARGS = {
    'state_dict': state_dict,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
extract_layer Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_prune.py
code served (permissive licence) · get_code("898331e04a7d1f91")
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 Conv2d. 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)

# Build a model with nested layers to test extraction
class SimpleBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 4, 3)
        self.conv2 = nn.Conv2d(4, 8, 3)

class TestModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Sequential(
            SimpleBlock(),
            SimpleBlock()
        )
        self.layer2 = nn.Linear(8, 10)
        self.fc = nn.Linear(10, 5)

model = TestModel()

# Test with a simple dot-separated layer path
layer_path = "layer1.0.conv1"

ARGS = {
    "model": model,
    "layer": layer_path
}
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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
feature_take_indices Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_features.py
code served (permissive licence) · get_code("48e288ce9fd8bd47")
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 typing import Dict, List, Optional, Union

torch.manual_seed(0)

# Define ARGS with all parameters for feature_take_indices
ARGS = {
    'num_features': 10,
    'indices': None,
    'as_set': False,
}

# Test case 1: with indices as None (select all)
ARGS_1 = {
    'num_features': 10,
    'indices': None,
    'as_set': False,
}

# Test case 2: with indices as int (select last n)
ARGS_2 = {
    'num_features': 10,
    'indices': 3,
    'as_set': False,
}

# Test case 3: with indices as list
ARGS_3 = {
    'num_features': 10,
    'indices': [0, 2, 5, -1],
    'as_set': False,
}

# Test case 4: with as_set=True
ARGS_4 = {
    'num_features': 10,
    'indices': [1, 3, 5],
    'as_set': True,
}

ARGS = ARGS_1
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, 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
filter_pretrained_cfg Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_pretrained.py
code served (permissive licence) · get_code("defd8a40081ed476")
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 dict. 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)

# Construct a sample pretrained config dictionary
cfg = {
    'url': 'https://example.com/model.pth',
    'file': 'model.pth',
    'hf_hub_id': 'user/model',
    'hf_hub_filename': 'pytorch_model.bin',
    'source': 'timm',
    'pool_size': (7, 7),
    'first_conv': None,
    'classifier': None,
    'num_classes': 1000,
    'input_size': (3, 224, 224),
    'interpolation': 'bicubic',
    'mean': [0.485, 0.456, 0.406],
    'std': [0.229, 0.224, 0.225],
    'crop_pct': 0.875,
    'test_input_size': (3, 256, 256),
    'test_crop_pct': 1.0,
    'license': 'apache-2.0',
    'description': 'ResNet-50 model',
    'origin': None,
}

ARGS = {
    'cfg': cfg,
    'remove_source': True,
    'remove_null': True,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
get_arch_name Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_registry.py
code served (permissive licence) · get_code("71420893c20b5733")
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 str. 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

def split_model_name_tag(model_name: str, no_tag: str='') -> tuple:
    model_name, *tag_list = model_name.split('.', 1)
    tag = tag_list[0] if tag_list else no_tag
    return (model_name, tag)

def get_arch_name(model_name: str) -> str:
    return split_model_name_tag(model_name)[0]

# Test setup - the function takes a model_name string and extracts the architecture name
# by splitting on '.' and taking the first part

ARGS = {
    'model_name': 'resnet50.v1'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_cache_dir Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_hub.py
code served (permissive licence) · get_code("bff72f1ca085c243")
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 str. 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 os
import tempfile

# Mock the get_dir function that's called in get_cache_dir
def get_dir():
    """Mock implementation of get_dir that returns a temporary directory."""
    temp_dir = tempfile.gettempdir()
    return temp_dir

# Inject the mock into the module namespace
import sys
current_module = sys.modules[__name__]
current_module.get_dir = get_dir

ARGS = {
    'child_dir': 'test_models'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
group_with_matcher Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_manipulate.py
code served (permissive licence) · get_code("4b76ad7d1ac46ef1")
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 defaultdict. 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 re
from collections import defaultdict
from itertools import chain
import collections.abc
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union

torch.manual_seed(0)

# Define a simple named_objects iterator
def create_named_objects():
    objects = [
        ("layer.0.weight", "weight_0"),
        ("layer.0.bias", "bias_0"),
        ("layer.1.weight", "weight_1"),
        ("layer.1.bias", "bias_1"),
        ("layer.2.weight", "weight_2"),
        ("layer.2.bias", "bias_2"),
    ]
    return iter(objects)

# Define a dict-based group_matcher
group_matcher_dict = {
    "layer_weights": [
        (r"layer\.(\d+)\.weight", None),
    ],
    "layer_biases": [
        (r"layer\.(\d+)\.bias", None),
    ],
}

# Define a callable group_matcher as an alternative
def group_matcher_fn(name: str) -> Tuple[int, ...]:
    if "weight" in name:
        return (0,)
    elif "bias" in name:
        return (1,)
    else:
        return (float('inf'),)

ARGS = {
    "named_objects": create_named_objects(),
    "group_matcher": group_matcher_dict,
    "return_values": False,
    "reverse": 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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
load_state_dict Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_helpers.py
code served (permissive licence) · get_code("7fdbe56543eec6df")
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 dict. 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 os
import tempfile
from typing import Dict, Any

torch.manual_seed(0)

# Create a temporary directory for checkpoint files
temp_dir = tempfile.mkdtemp()

# Create a simple checkpoint file with state dict
checkpoint_data = {
    'state_dict': {
        'layer1.weight': torch.randn(3, 4),
        'layer1.bias': torch.randn(3),
        'layer2.weight': torch.randn(2, 3),
    }
}

checkpoint_path = os.path.join(temp_dir, 'checkpoint.pt')
torch.save(checkpoint_data, checkpoint_path)

# Define ARGS dict with all parameters for load_state_dict
ARGS = {
    'checkpoint_path': checkpoint_path,
    'use_ema': True,
    'device': 'cpu',
    'weights_only': True,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
model_parameters Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_manipulate.py
code served (permissive licence) · get_code("3a0b8256d1b7f59b")
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 generator. 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 import nn

torch.manual_seed(0)

# Build a simple model with parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.layer1(x)
        x = self.layer2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model,
    "exclude_head": 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 generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator 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
named_apply Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_manipulate.py
code served (permissive licence) · get_code("a5a76ed642ff8b50")
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 NestedModule. 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 nested module structure
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)

class NestedModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = SimpleModule()
        self.layer2 = nn.Linear(3, 2)
        self.layer3 = SimpleModule()

# Create the module to apply the function to
module = NestedModule()

# Define a simple callback function that the named_apply will call
def callback_fn(module, name):
    # This function just needs to accept module and name parameters
    pass

# Construct the ARGS dictionary
ARGS = {
    'fn': callback_fn,
    'module': module,
    'name': '',
    'depth_first': True,
    'include_root': 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 NestedModule — a NestedModule output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NestedModule 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
num_groups Ran
ran, honoured the contract we drafted
huggingface/pytorch-image-models/timm/models/_efficientnet_blocks.py
code served (permissive licence) · get_code("ee32bf858fbcf8a1")
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 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 torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "group_size": 2,
    "channels": 8,
}
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 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
padding Ran
ran; our contract draft was wrong, not the code
rstrudel/segmenter/segm/model/utils.py
code served (permissive licence) · get_code("ea8774732f2172da")
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, 6, 9) 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.functional as F

torch.manual_seed(0)

# Create a small image tensor with batch size 2, channels 4, height 5, width 7
# Shape: (batch, channels, height, width)
im = torch.randn(2, 4, 5, 7)

# Define patch_size
patch_size = 3

# Define fill_value
fill_value = 0

ARGS = {
    "im": im,
    "patch_size": patch_size,
    "fill_value": fill_value,
}
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, 6, 9) — shape (2, 4, 6, 9) 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
parse_model_name Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_factory.py
code served (permissive licence) · get_code("bedcb4d11b5dd0c3")
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 1, 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 re
from typing import Any, Dict, Optional, Tuple, Union

_MODEL_SOURCES = ('hf-hub', 'local-dir')

_MODEL_SOURCE_ALIASES = {'hf_hub': 'hf-hub'}

_SOURCE_PREFIX_PATTERN = re.compile('[a-zA-Z][a-zA-Z0-9+.\\-_]+')

_PATH_CHARS = ('/', '\\', ':')

def parse_model_name(model_name: str) -> Tuple[Optional[str], str]:
    """Parse source and name from potentially prefixed model name.

    Everything after a recognized source prefix is treated as an opaque identifier (a Hugging Face
    Hub repo id or a local filesystem path). It is deliberately not URL parsed, so Windows drive
    letters, UNC paths, and paths containing characters such as '#', '?' or '@' pass through as-is.

    Args:
        model_name: Model name, optionally prefixed with a source, e.g. ``hf-hub:timm/resnet18.a1_in1k``
            or ``local-dir:/path/to/model_folder``.

    Returns:
        Tuple of (source, model_id). Source is None for plain (timm registry) model names.

    Raises:
        ValueError: If a source prefix is present but unknown, or has an empty model id. Also if no prefix
            is present but the name looks like a path or Hub repo id, as falling back to a registry model
            of the same basename would silently load different weights (or drop the repo owner).
    """
    source, sep, model_id = model_name.partition(':')
    if not sep or not _SOURCE_PREFIX_PATTERN.fullmatch(source):
        if any((c in model_name for c in _PATH_CHARS)):
            raise ValueError(f"Model name '{model_name}' has no source prefix but looks like a Hugging Face Hub repo id or a local path. Use 'hf-hub:{model_name}' to load from the Hub or 'local-dir:{model_name}' to load from a local folder.")
        return (None, model_name)
    source = source.lower()
    source = _MODEL_SOURCE_ALIASES.get(source, source)
    if source not in _MODEL_SOURCES:
        raise ValueError(f"Unknown model source '{source}' in model name '{model_name}', valid sources: {', '.join(_MODEL_SOURCES)}.")
    if not model_id:
        raise ValueError(f"Model name '{model_name}' has no model id / path after the '{source}:' prefix.")
    return (source, model_id)


ARGS = {
    'model_name': 'hf-hub:timm/resnet18.a1_in1k'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
pretrained_cfg_for_features Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_builder.py
code served (permissive licence) · get_code("8c44f3adfa3f0955")
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 dict. 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 copy import deepcopy

torch.manual_seed(0)

# Construct a sample pretrained_cfg dictionary
# This is a typical config that might be used for model pretraining
pretrained_cfg = {
    'num_classes': 1000,
    'classifier': 'linear',
    'global_pool': 'avg',
    'url': 'https://example.com/model.pth',
    'architecture': 'resnet50',
    'input_size': (3, 224, 224),
    'crop_pct': 0.875,
    'interpolation': 'bicubic',
    'mean': [0.485, 0.456, 0.406],
    'std': [0.229, 0.224, 0.225],
    'first_conv': 'conv1',
    'pool_size': (7, 7),
}

ARGS = {
    'pretrained_cfg': pretrained_cfg
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
resize_pos_embed Ran
ran; our contract draft was wrong, not the code
rstrudel/segmenter/segm/model/utils.py
code served (permissive licence) · get_code("039235a9d747b605")
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 (1, 22, 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 math

torch.manual_seed(0)

# Construct a position embedding tensor
# Structure: [batch, num_tokens, embed_dim]
# num_tokens = num_extra_tokens + (grid_h * grid_w)
batch_size = 1
num_extra_tokens = 2
embed_dim = 4
grid_old_h = 3
grid_old_w = 3
grid_new_h = 4
grid_new_w = 5

# Total tokens: 2 (extra) + 3*3 (grid) = 11
num_grid_tokens = grid_old_h * grid_old_w
total_tokens = num_extra_tokens + num_grid_tokens

# Create position embedding tensor: [batch, total_tokens, embed_dim]
posemb = torch.randn(batch_size, total_tokens, embed_dim)

grid_old_shape = (grid_old_h, grid_old_w)
grid_new_shape = (grid_new_h, grid_new_w)

ARGS = {
    "posemb": posemb,
    "grid_old_shape": grid_old_shape,
    "grid_new_shape": grid_new_shape,
    "num_extra_tokens": num_extra_tokens,
}
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 (1, 22, 4) — shape (1, 22, 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
resolve_act_layer Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_efficientnet_builder.py
code served (permissive licence) · get_code("56a5da7d42544f6f")
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 type. 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
from timm.layers import get_act_layer

torch.manual_seed(0)

# resolve_act_layer expects:
# 1. kwargs: a dict that may contain 'act_layer' key
# 2. default: a string (default='relu')

# Test case 1: kwargs with act_layer specified
kwargs_with_act = {'act_layer': 'gelu'}

# Test case 2: kwargs without act_layer (will use default)
kwargs_without_act = {'other_param': 'value'}

# For the function to work, we need to provide kwargs as a dict
# The function pops 'act_layer' from it, so we pass a dict
# and a default value

ARGS = {
    'kwargs': {'act_layer': 'relu'},
    'default': 'relu'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
resolve_bn_args Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_efficientnet_builder.py
code served (permissive licence) · get_code("ad5c779c4dbc8362")
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 dict. 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 = {
    'kwargs': {
        'bn_momentum': 0.1,
        'bn_eps': 1e-5
    }
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
resolve_pretrained_cfg Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_builder.py
code served (permissive licence) · get_code("6c7b25e3ed22f8fb")
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 PretrainedCfg. 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 dataclasses
from typing import Any, Dict, Optional, Union
from timm.models._pretrained import PretrainedCfg

# Mock the get_pretrained_cfg function since we can't import from timm.models._registry
def mock_get_pretrained_cfg(model_with_tag: str) -> Optional[PretrainedCfg]:
    """Mock function that returns a PretrainedCfg for known tags."""
    if model_with_tag == "resnet50.default":
        return PretrainedCfg(
            url="https://example.com/model.pth",
            architecture="resnet50",
            tag="default"
        )
    return None

# Monkey-patch the import
import sys
import types
timm_models_registry = types.ModuleType('timm.models._registry')
timm_models_registry.get_pretrained_cfg = mock_get_pretrained_cfg
sys.modules['timm.models._registry'] = timm_models_registry

# Now we can construct valid arguments
ARGS = {
    "variant": "resnet50",
    "pretrained_cfg": {
        "url": "https://example.com/model.pth",
        "architecture": "resnet50",
        "tag": "default"
    },
    "pretrained_cfg_overlay": {
        "input_size": (3, 224, 224),
        "num_classes": 1000
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PretrainedCfg — a PretrainedCfg output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PretrainedCfg 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
round_channels Ran
ran, honoured the contract we drafted
huggingface/pytorch-image-models/timm/models/_efficientnet_builder.py
code served (permissive licence) · get_code("65cde5ce166fdb56")
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 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
from timm.layers import make_divisible

torch.manual_seed(0)

ARGS = {
    "channels": 64,
    "multiplier": 1.0,
    "divisor": 8,
    "channel_min": None,
    "round_limit": 0.9,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, timm, 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
safe_model_name Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_factory.py
code served (permissive licence) · get_code("0afae0ca3336fe37")
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 str. 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 re
from typing import Any, Dict, Optional, Tuple, Union

_MODEL_SOURCES = ('hf-hub', 'local-dir')

_MODEL_SOURCE_ALIASES = {'hf_hub': 'hf-hub'}

_SOURCE_PREFIX_PATTERN = re.compile('[a-zA-Z][a-zA-Z0-9+.\\-_]+')

_PATH_CHARS = ('/', '\\', ':')

def parse_model_name(model_name: str) -> Tuple[Optional[str], str]:
    """Parse source and name from potentially prefixed model name.

    Everything after a recognized source prefix is treated as an opaque identifier (a Hugging Face
    Hub repo id or a local filesystem path). It is deliberately not URL parsed, so Windows drive
    letters, UNC paths, and paths containing characters such as '#', '?' or '@' pass through as-is.

    Args:
        model_name: Model name, optionally prefixed with a source, e.g. ``hf-hub:timm/resnet18.a1_in1k``
            or ``local-dir:/path/to/model_folder``.

    Returns:
        Tuple of (source, model_id). Source is None for plain (timm registry) model names.

    Raises:
        ValueError: If a source prefix is present but unknown, or has an empty model id. Also if no prefix
            is present but the name looks like a path or Hub repo id, as falling back to a registry model
            of the same basename would silently load different weights (or drop the repo owner).
    """
    source, sep, model_id = model_name.partition(':')
    if not sep or not _SOURCE_PREFIX_PATTERN.fullmatch(source):
        if any((c in model_name for c in _PATH_CHARS)):
            raise ValueError(f"Model name '{model_name}' has no source prefix but looks like a Hugging Face Hub repo id or a local path. Use 'hf-hub:{model_name}' to load from the Hub or 'local-dir:{model_name}' to load from a local folder.")
        return (None, model_name)
    source = source.lower()
    source = _MODEL_SOURCE_ALIASES.get(source, source)
    if source not in _MODEL_SOURCES:
        raise ValueError(f"Unknown model source '{source}' in model name '{model_name}', valid sources: {', '.join(_MODEL_SOURCES)}.")
    if not model_id:
        raise ValueError(f"Model name '{model_name}' has no model id / path after the '{source}:' prefix.")
    return (source, model_id)

def safe_model_name(model_name: str, remove_source: bool=True) -> str:
    """Return a filename / path safe model name."""

    def make_safe(name: str) -> str:
        return ''.join((c if c.isalnum() else '_' for c in name)).rstrip('_')
    if remove_source:
        model_name = parse_model_name(model_name)[-1]
    return make_safe(model_name)


ARGS = {
    'model_name': 'hf-hub:timm/resnet18.a1_in1k',
    'remove_source': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
split_model_name_tag Ran
ran; our contract draft was wrong, not the code
huggingface/pytorch-image-models/timm/models/_registry.py
code served (permissive licence) · get_code("de9c9579e64472b9")
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 1, 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

def split_model_name_tag(model_name: str, no_tag: str='') -> tuple:
    model_name, *tag_list = model_name.split('.', 1)
    tag = tag_list[0] if tag_list else no_tag
    return (model_name, tag)

# Test case 1: model_name with a tag
model_name_1 = "resnet50.v1"
no_tag_1 = ""

# Test case 2: model_name without a tag
model_name_2 = "bert"
no_tag_2 = "default"

# Test case 3: model_name with multiple dots (only first dot should be used as separator)
model_name_3 = "gpt2.large.fp16"
no_tag_3 = ""

ARGS = {
    "model_name": "resnet50.v2",
    "no_tag": "default"
}
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 1, 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
DTEMAttention Not yet run
unverified (harvested, no recorded run)
movinghoon/dtem/dtem/dtem.py
pointer only (licence: NONE) · get_code("7b5a91a2560665c1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, movinghoon/dtem 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.

DTEMBlock Not yet run
unverified (harvested, no recorded run)
movinghoon/dtem/dtem/dtem.py
pointer only (licence: NONE) · get_code("558cf4de74c46eaa")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, movinghoon/dtem 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.

adapt_model_from_file Not yet run
unverified (harvested, no recorded run)
huggingface/pytorch-image-models/timm/models/_prune.py
code served (permissive licence) · get_code("4db2d30920cae61a")
How it ran

no invocation recorded.

build_model_with_cfg Not yet run
unverified (harvested, no recorded run)
huggingface/pytorch-image-models/timm/models/_builder.py
code served (permissive licence) · get_code("1a83aa6714f69ef7")
How it ran

no invocation recorded.

download_cached_file Not yet run
unverified (harvested, no recorded run)
huggingface/pytorch-image-models/timm/models/_hub.py
code served (permissive licence) · get_code("5a0d348f6fe9632c")
How it ran

no invocation recorded.

load_checkpoint Not yet run
unverified (harvested, no recorded run)
huggingface/pytorch-image-models/timm/models/_helpers.py
code served (permissive licence) · get_code("424e56c681fbb7c2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 34 samples lifted from this paper's linked repositories, 34 carry a function identity and 0 do not. Of the 34 distinct functions with an identity, 15 are also present in other papers whose code we hold (14 with at least one paper dated earlier, 0 the same month, 4 later) and 19 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
bipartite_soft_matching
brick of this paper's assembly: helper
6 other papers
6 dated earlier
2210.09461 (2022-10)
Token Merging: Your ViT But Faster
2307.10780 (2023-07)
Learned Thresholds Token Merging and Pruning for Vision Transformers
2310.01812 (2023-10)
PPT: Token Pruning and Pooling for Efficient Vision Transformers
and 3 more not named here
extract_layer 4 other papers
3 dated earlier, 1 later
2002.08258 (2020-02)
Knapsack Pruning with Inner Distillation
2203.10233 (2022-03)
DirecFormer: A Directed Attention in Transformer Approach to Robust Action Recognition
2407.03179 (2024-07)
Motion meets Attention: Video Motion Prompts
and 1 more not named here
resize_pos_embed 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable · 1 only as an assembly brick
2301.10222 (2023-01)
RangeViT: Towards Vision Transformers for 3D Semantic Segmentation in Autonomous Driving
2308.15512 (2023-08)
Shatter and Gather: Learning Referring Image Segmentation with Text Supervision
and 1 more not named here
accuracy 3 other papers
2 dated earlier, 1 later
2105.05633 (2021-05)
Segmenter: Transformer for Semantic Segmentation
2406.09936 (2024-06)
ALGM: Adaptive Local-then-Global Token Merging for Efficient Semantic Segmentation with Plain Vision Transformers
named_apply 3 other papers
3 dated earlier
2402.12138 (2024-02)
Perceiving Longer Sequences With Bi-Directional Cross-Attention Transformers
2407.19985 (2024-07)
Mixture of Nested Experts: Adaptive Processing of Visual Tokens
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
blend_im 1 other paper
1 dated earlier
2304.01184 (2023-04)
WeakTr: Exploring Plain Vision Transformer for Weakly-supervised Semantic Segmentation
checkpoint_filter_fn 1 other paper
1 later
Bergner_Token_Cropr_Faster_ViTs_for_Quite_a_Few_Tasks_CVPR_2025_paper (2025 (year only))
Token Cropr: Faster ViTs for Quite a Few Tasks
filter_pretrained_cfg 1 other paper
1 dated earlier
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
get_arch_name 1 other paper
1 dated earlier
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
group_with_matcher 1 other paper
1 dated earlier
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
model_parameters 1 other paper
1 dated earlier
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
num_groups 1 other paper
1 dated earlier
2404.10518 (2024-04)
MobileNetV4 -- Universal Models for the Mobile Ecosystem
resolve_act_layer 1 other paper
1 dated earlier
2404.10518 (2024-04)
MobileNetV4 -- Universal Models for the Mobile Ecosystem
resolve_bn_args 1 other paper
1 dated earlier
2404.10518 (2024-04)
MobileNetV4 -- Universal Models for the Mobile Ecosystem
split_model_name_tag 1 other paper
1 dated earlier
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection

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

Recent token reduction methods for Vision Transformers (ViTs) incorporate token merging, which measures the similarities between token embeddings and combines the most similar pairs. However, their merging policies are directly dependent on intermediate features in ViTs, which prevents exploiting features tailored for merging and requires end-to-end training to improve token merging. This paper proposes Decoupled Token Embedding for Merging (DTEM) that enhances token merging through a decoupled embedding learned via a continuously relaxed token merging process. Our method introduces a lightweight embedding module decoupled from the ViT forward pass to extract dedicated features for token merging, addressing the restriction from using intermediate features. The continuously relaxed token merging, applied during training, enables us to learn the decoupled embeddings in a differentiable manner. Thanks to the decoupled structure, our method can be seamlessly integrated into existing ViT backbones and trained either modularly by learning only the decoupled embeddings or end-to-end by fine-tuning. We demonstrate the applicability of DTEM on various tasks, including classification, captioning, and segmentation, with consistent improvement in token merging. Especially in the ImageNet-1k classification, DTEM achieves a 37.2% reduction in FLOPs while maintaining a top-1 accuracy of 79.85% with DeiT-small. Code is available at https://github.com/movinghoon/dtem.

For agents

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

get_harvested_code_for_paper("2412.10569")
get_code_for_paper("2412.10569")
have("2412.10569")

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

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

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

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

Connect an agent — have() is free.