SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.04763 · ICLR · 2022

Imitation Learning by Reinforcement Learning

Kamil Ciosek

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 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; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-21; 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/2108.04763.json · badge: /api/ran/2108.04763.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
spotify-research/il-by-rl canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
FunctionStatusWhere it lives
evaluate Ran
ran on a synthesized input
spotify-research/il-by-rl/d4rl_train.py
code served (permissive licence) · get_code("16e011ab8b9dc3a6")
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 float64, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

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

torch.manual_seed(0)

# Create a minimal environment that matches the expected interface
class SimpleEnv:
    def __init__(self):
        self.obs_dim = 4
        self.action_dim = 2
        self.step_count = 0
        self.max_steps = 5
    
    def reset(self):
        self.step_count = 0
        return np.random.randn(self.obs_dim).astype(np.float32)
    
    def step(self, action):
        self.step_count += 1
        obs = np.random.randn(self.obs_dim).astype(np.float32)
        reward = float(np.random.randn())
        terminated = self.step_count >= self.max_steps
        info = {}
        return obs, reward, terminated, info

# Create a minimal SAC agent that matches the expected interface
class SimpleSAC(nn.Module):
    def __init__(self, obs_dim=4, action_dim=2):
        super().__init__()
        self.policy = nn.Linear(obs_dim, action_dim)
    
    def act(self, obs_list, deterministic=True):
        # obs_list is a list of observations
        # Convert to tensor and forward through policy
        obs_array = np.array(obs_list, dtype=np.float32)
        obs_tensor = torch.from_numpy(obs_array)
        with torch.no_grad():
            actions = self.policy(obs_tensor)
        # Return list of actions (one per observation)
        actions_np = actions.numpy()
        if actions_np.ndim == 1:
            actions_np = actions_np.reshape(1, -1)
        return [actions_np[i] for i in range(actions_np.shape[0])]

env = SimpleEnv()
sac = SimpleSAC(obs_dim=4, action_dim=2)

ARGS = {
    "env": env,
    "sac": sac,
    "n_episodes": 2
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
execute Ran
ran on a synthesized input
spotify-research/il-by-rl/utils.py
code served (permissive licence) · get_code("25bd681eec65f985")
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)

def sample_function():
    """A simple callable that returns a value"""
    return 42

ARGS = {
    "function": sample_function
}
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
get_small_dataset Ran
ran on a synthesized input
spotify-research/il-by-rl/utils.py
code served (permissive licence) · get_code("56439c9c4f8ee150")
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 math
import numpy as np

# Create small numpy arrays for observations and expert actions
np.random.seed(0)
dataset_size = 10
obs_dim = 4
action_dim = 3

# full_obs_t: shape (dataset_size, obs_dim)
full_obs_t = np.random.randn(dataset_size, obs_dim).astype(np.float32)

# full_expert_a_t: shape (dataset_size, action_dim)
full_expert_a_t = np.random.randn(dataset_size, action_dim).astype(np.float32)

ARGS = {
    "percent_data": 50,
    "dataset_size": dataset_size,
    "full_obs_t": full_obs_t,
    "full_expert_a_t": full_expert_a_t,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
make_buffer_next Ran
ran on a synthesized input
spotify-research/il-by-rl/train_il_functions.py
code served (permissive licence) · get_code("b75128f3d89fb6e7")
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 3, 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 copy
import torch

torch.manual_seed(0)

# The function make_buffer_next takes a buffer parameter
# It uses copy.deepcopy() on it and calls .pop(0) on it
# So buffer needs to be a list-like object that supports pop()

# Create a simple buffer as a list of tensors or dicts
buffer = [
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
]

ARGS = {
    "buffer": buffer,
}
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 3, 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
optimization_step Ran
ran on a synthesized input
spotify-research/il-by-rl/train_bc_functions.py
code served (permissive licence) · get_code("315c8276b87bb7ac")
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 float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

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

torch.manual_seed(0)

# Define a simple actor model that satisfies the function's requirements
class SimpleActor(nn.Module):
    def __init__(self, obs_dim=4, action_dim=3):
        super().__init__()
        self.fc = nn.Linear(obs_dim, action_dim * 2)  # output mean and stdev
        
    def forward(self, obs, deterministic=False, with_log_prob=False, with_stdev=False):
        x = self.fc(obs)
        mean = x[:, :x.shape[1]//2]
        stdev = torch.abs(x[:, x.shape[1]//2:]) + 0.01  # ensure positive
        
        if with_stdev:
            return mean, stdev
        return mean

# Create model
bc_actor = SimpleActor(obs_dim=4, action_dim=3)

# Parameters
batch_size_bc = 2
small_dataset_size = 5
obs_dim = 4
action_dim = 3

# Create small dataset tensors
smallds_obs_t = torch.randn(small_dataset_size, obs_dim)
smallds_expert_a_t = torch.randn(small_dataset_size, action_dim)

# Create optimizer
optimizer = torch.optim.Adam(bc_actor.parameters(), lr=0.001)

# Create RNG (numpy random)
rng = np.random.RandomState(42)

# Losses list
losses = []

ARGS = {
    "bc_actor": bc_actor,
    "batch_size_bc": batch_size_bc,
    "losses": losses,
    "optimizer": optimizer,
    "rng": rng,
    "small_dataset_size": small_dataset_size,
    "smallds_expert_a_t": smallds_expert_a_t,
    "smallds_obs_t": smallds_obs_t,
}
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 float, 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
update Ran
ran on a synthesized input
spotify-research/il-by-rl/d4rl_train.py
code served (permissive licence) · get_code("c311e1212eabc873")
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
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Define a minimal SAC agent with required methods
class MinimalSAC(nn.Module):
    def __init__(self):
        super().__init__()
        self.critic_net = nn.Linear(8, 1)
        self.actor_net = nn.Linear(4, 3)
        self.temp_net = nn.Linear(4, 1)
    
    def update_critic(self, obs_ts, act_ts, rew_tp1s, obs_tp1s, ter_tp1s):
        # Method is called with lists of observations, actions, rewards, next obs, terminals
        return torch.tensor(0.5, dtype=torch.float32)
    
    def update_actor(self, obs_ts):
        # Method is called with list of observations
        return torch.tensor(0.3, dtype=torch.float32)
    
    def update_temp(self, obs_ts):
        # Method is called with list of observations
        return torch.tensor(0.1, dtype=torch.float32)
    
    def update_target(self):
        # No-op method
        pass

# Create a buffer as a list of tuples
# Each element: (obs, action, reward, terminal_flag)
# The function accesses buffer[index] and buffer[index+1]
# buffer[index][0] = obs_t
# buffer[index][1] = action_t
# buffer[index+1][2] = reward_{t+1}
# buffer[index+1][0] = obs_{t+1}
# buffer[index+1][3] = terminal_{t+1}
# buffer[index][3][0] = terminal_t (checked to skip)

buffer = []
for i in range(10):
    obs = torch.randn(4, dtype=torch.float32)
    action = torch.randn(3, dtype=torch.float32)
    reward = torch.tensor(0.5, dtype=torch.float32)
    terminal = torch.tensor([False], dtype=torch.bool)
    buffer.append((obs, action, reward, terminal))

sac = MinimalSAC()
batch_size = 2
train_actor = True

ARGS = {
    'buffer': buffer,
    'sac': sac,
    'batch_size': batch_size,
    'train_actor': train_actor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, 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
update Ran
ran on a synthesized input
spotify-research/il-by-rl/d4rl_train_sqil.py
code served (permissive licence) · get_code("52dbc718a25a63ce")
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
import numpy as np
from torch import nn

torch.manual_seed(0)
np.random.seed(0)

# Stand-in SAC agent with required methods
class StandInSAC(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(4, 4)
    
    def update_critic(self, obs_ts, act_ts, rew_tp1s, obs_tp1s, ter_tp1s):
        return 0.5
    
    def update_actor(self, obs_ts):
        return 0.3
    
    def update_temp(self, obs_ts):
        return 0.1
    
    def update_target(self):
        pass

# Create buffer entries: (obs, act, reward, terminal)
# obs is shape (4,), act is shape (3,), reward is scalar, terminal is array
def create_buffer_entry():
    obs = np.random.randn(4).astype(np.float32)
    act = np.random.randn(3).astype(np.float32)
    reward = np.float32(np.random.randn())
    terminal = np.array([False])
    return (obs, act, reward, terminal)

# Create buffers with enough entries to sample from
buffer = [create_buffer_entry() for _ in range(100)]
buffer_il = [create_buffer_entry() for _ in range(100)]

# Ensure no terminal states at sampled indices to avoid skipping
for i in range(len(buffer) - 1):
    buffer[i] = (buffer[i][0], buffer[i][1], buffer[i][2], np.array([False]))
for i in range(len(buffer_il) - 1):
    buffer_il[i] = (buffer_il[i][0], buffer_il[i][1], buffer_il[i][2], np.array([False]))

sac = StandInSAC()
batch_size = 4

ARGS = {
    'buffer': buffer,
    'buffer_il': buffer_il,
    'sac': sac,
    'batch_size': batch_size,
    'train_actor': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, 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
get_binary_reward Not yet run
unverified (harvested, no recorded run)
spotify-research/il-by-rl/train_il_functions.py
code served (permissive licence) · get_code("58f5a0296ffac801")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

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

Repositories linked to this paper

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

Abstract

Imitation learning algorithms learn a policy from demonstrations of expert behavior. We show that, for deterministic experts, imitation learning can be done by reduction to reinforcement learning with a stationary reward. Our theoretical analysis both certifies the recovery of expert reward and bounds the total variation distance between the expert and the imitation learner, showing a link to adversarial imitation learning. We conduct experiments which confirm that our reduction works well in practice for continuous control tasks.

For agents

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

get_harvested_code_for_paper("2108.04763")
get_code_for_paper("2108.04763")
have("2108.04763")

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

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

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

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

Connect an agent — have() is free.