SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.19225 · 2025

Unified Medical Image Tokenizer for Autoregressive Synthesis and Understanding

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 5 failures of our instrument; 0 no recorded run), measured 2026-11-23; 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/2505.19225.json · badge: /api/ran/2505.19225.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
masaaki-75/meditok canonical (classifier label)
classifier basis not recorded on the link
10 ran · 0 no recorded run
FunctionStatusWhere it lives
add_residual Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
masaaki-75/meditok/layers/block.py
code served (permissive licence) · get_code("5d16d4d4fc573ac7")
How it ran

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

import torch

torch.manual_seed(0)

# Build tiny tensors for the function arguments
# x: input tensor, shape (batch=2, features=4)
x = torch.randn(2, 4, dtype=torch.float32)

# brange: indices for where to add residual, shape should be compatible with batch dimension
brange = torch.tensor([0, 1], dtype=torch.long)

# residual: tensor to add, same shape as x
residual = torch.randn(2, 4, dtype=torch.float32)

# residual_scale_factor: scalar multiplier
residual_scale_factor = 0.5

# scaling_vector: optional vector for scaled operations, set to None for first branch
scaling_vector = None

ARGS = {
    "x": x,
    "brange": brange,
    "residual": residual,
    "residual_scale_factor": residual_scale_factor,
    "scaling_vector": scaling_vector,
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_file_ok Ran
ran on a synthesized input
masaaki-75/meditok/batch_infer.py
code served (permissive licence) · get_code("a9fc31a45465d6c8")
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 tempfile
import os
from PIL import Image

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

# Create a valid PNG image
valid_png_path = os.path.join(temp_dir, "test_image.png")
img = Image.new('RGB', (10, 10), color='red')
img.save(valid_png_path, 'PNG')

# Use the valid PNG path as the argument
ARGS = {
    "path": valid_png_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — 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
drop_add_residual_stochastic_depth Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
masaaki-75/meditok/layers/block.py
code served (permissive licence) · get_code("85f7ffc01945bb72")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 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, Tensor
from typing import Callable

torch.manual_seed(0)

# Create a simple residual function that takes a tensor and returns a tensor of same shape
class SimpleResidualFunc(nn.Module):
    def __init__(self, dim: int):
        super().__init__()
        self.linear = nn.Linear(dim, dim)
    
    def forward(self, x: Tensor) -> Tensor:
        # x will have shape (sample_subset_size, n, d)
        # We need to return same shape
        b, n, d = x.shape
        x_flat = x.flatten(1)  # (b, n*d)
        out = self.linear(x_flat)  # (b, n*d)
        return out.view(b, n, d)

# Create input tensor with shape (batch=2, n=3, d=4)
x = torch.randn(2, 3, 4)

# Create a residual function
residual_func = SimpleResidualFunc(dim=3*4)

# Define the sample_drop_ratio parameter
sample_drop_ratio = 0.1

ARGS = {
    "x": x,
    "residual_func": residual_func,
    "sample_drop_ratio": sample_drop_ratio
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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
drop_path Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
masaaki-75/meditok/layers/drop_path.py
code served (permissive licence) · get_code("c157f5b112b3a392")
How it ran

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

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a small tensor for drop_path
# The function uses x.shape[0] for batch dimension and x.ndim for number of dimensions
# It also calls x.new_empty() and performs element-wise operations
x = torch.randn(2, 4, 3, 5)  # batch=2, then 3 other dimensions with distinct sizes

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

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

import torch

torch.manual_seed(0)

# Construct a small tensor with shape (batch=2, sequence=4, dim=3)
x = torch.randn(2, 4, 3)

# Define arguments
ARGS = {
    "x": x,
    "sample_drop_ratio": 0.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_meditok_args Ran
ran on a synthesized input
masaaki-75/meditok/models/meditok.py
code served (permissive licence) · get_code("9cfe67ef3f283984")
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 DotDict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class DotDict:
    def __init__(self, dictionary):
        for key, value in dictionary.items():
            if isinstance(value, dict):
                value = DotDict(value)
            setattr(self, key, value)

def get_meditok_args(img_size=256, grad_ckpt=False):
    return DotDict(dict(embed_dim=768, num_query=0, model='vitamin_large', img_size=img_size, drop_path=0, vocab_size=32768, vocab_width=64, vocab_norm=True, vq_beta=0.25, le=0.0, e_temp=0.01, num_codebooks=8, quant_proj='attn', grad_ckpt=grad_ckpt, device='cpu', drop_alignment=False))

ARGS = {
    'img_size': 256,
    'grad_ckpt': 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 DotDict — a DotDict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DotDict 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
make_2tuple Ran
ran, honoured the contract we drafted
masaaki-75/meditok/layers/patch_embed.py
code served (permissive licence) · get_code("3c04490a215299f2")
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 tuple, 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)

# Test case 1: tuple input with length 2
test_tuple = (5, 7)

# Test case 2: integer input
test_int = 3

# We'll create ARGS with the integer case
ARGS = {
    "x": test_int
}
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 tuple, ndim 1, dtype family int — 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
prepare_inputs_for_generation Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
masaaki-75/meditok/local_openclip/coca_model.py
pointer only (licence: MIT); the stored copy get_code serves, from WHU-USI3DV/TreeCLS, is pointer only (licence: NONE) · get_code("fb651d0a97fd4d3f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from WHU-USI3DV/TreeCLS, and GitHub detected no licence in that repository 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.

register_pooler Ran
ran on a synthesized input
masaaki-75/meditok/local_openclip/hf_model.py
pointer only (licence: MIT); the stored copy get_code serves, from WHU-USI3DV/TreeCLS, is pointer only (licence: NONE) · get_code("2a377da4a76a2d44")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from WHU-USI3DV/TreeCLS, and GitHub detected no licence in that repository 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.

stable_linear_transform Ran
ran on a synthesized input
masaaki-75/meditok/batch_infer.py
code served (permissive licence) · get_code("e814250e8fac9df2")
How it ran

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

import torch
import numpy as np

torch.manual_seed(0)

# Construct arguments for stable_linear_transform
x = torch.tensor([[0.2, 0.5, 0.8, 1.2],
                  [0.1, 0.3, 0.7, 0.9]], dtype=torch.float32)

y_min = 0
y_max = 1
x_min = None
x_max = None
do_clip = True

ARGS = {
    "x": x,
    "y_min": y_min,
    "y_max": y_max,
    "x_min": x_min,
    "x_max": x_max,
    "do_clip": do_clip
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 7 are also present in other papers whose code we hold (7 with at least one paper dated earlier, 0 the same month, 7 later) and 3 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
register_pooler 45 other papers
42 dated earlier, 2 later, 1 same year, order not determinable
2301.07094 (2023-01)
Learning Customized Visual Models with Retrieval-Augmented Knowledge
2302.03668 (2023-02)
Hard Prompts Made Easy: Gradient-Based Discrete Optimization for Prompt Tuning and Discovery
2303.14814 (2023-03)
WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation
and 42 more not named here
prepare_inputs_for_generation 43 other papers
38 dated earlier, 3 later, 2 same year, order not determinable
2301.07094 (2023-01)
Learning Customized Visual Models with Retrieval-Augmented Knowledge
2303.14814 (2023-03)
WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation
2305.07017 (2023-05)
An Inverse Scaling Law for CLIP Training
and 40 more not named here
drop_add_residual_stochastic_depth 21 other papers
16 dated earlier, 2 later, 1 same year, order not determinable, 2 undated
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
and 18 more not named here
make_2tuple 20 other papers
14 dated earlier, 5 later, 1 undated · 1 only as an assembly brick
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
and 17 more not named here
drop_path 18 other papers
12 dated earlier, 5 later, 1 undated · 2 only as an assembly brick
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
and 15 more not named here
add_residual 17 other papers
12 dated earlier, 3 later, 1 same year, order not determinable, 1 undated
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
2402.03138 (2024-02)
Just Cluster It: An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations
and 14 more not named here
get_branges_scales 17 other papers
12 dated earlier, 3 later, 1 same year, order not determinable, 1 undated
2304.07193 (2023-04)
DINOv2: Learning Robust Visual Features without Supervision
2312.02366 (2023-12)
Evaluating General Purpose Vision Foundation Models for Medical Image Analysis: An Experimental Study of DINOv2 on Radiology Benchmarks
2402.03138 (2024-02)
Just Cluster It: An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations
and 14 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-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

Autoregressive modeling has driven major advances in multimodal AI, yet its application to medical imaging remains constrained by the absence of a unified image tokenizer that simultaneously preserves fine-grained anatomical structures and rich clinical semantics across heterogeneous modalities. Existing approaches jointly optimize image reconstruction and textual semantic objectives, relying on large-scale image-caption pairs and are prone to gradient interference. This is ill-suited for the medical domain where paired data are scarce and abundant unpaired images remain unexploited. This work identifies these issues in building unified medical image tokenizers, and introduces a principled two-stage training framework using visual representation as a bridge to address them. The propose visual representation alignment stage enables the utilization of large-scale unpaired medical images to ensure reconstruction fidelity and establish foundational semantics, alleviating the interference and better preparing for the second stage where fine-grained textual semantics are injected using image-text pairs. The resulting tokenizer, MedITok, is trained on over 33 million medical images spanning 9 modalities and 2 million image-text pairs. MedITok achieves state-of-the-art performance on 30+ benchmarks spanning 9 imaging modalities and 4 task families. It further enables autoregressive modeling for diagnostic and generative applications, serving as a scalable component for future multimodal models with unified synthesis and understanding capabilities in the medical domain. Project page: https://github.com/Masaaki-75/meditok

For agents

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

get_harvested_code_for_paper("2505.19225")
get_code_for_paper("2505.19225")
have("2505.19225")

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

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

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

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

Connect an agent — have() is free.