[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: dataset_drift

Broken script:
```python
"""DistilRoberta sentiment classification on 400-sample IMDB subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("imdb", split="train[:400]")
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")

def tokenize(examples):
    return tokenizer(
        examples["input_text"],
        padding="max_length",
        truncation=True,
        max_length=64,
    )

dataset = dataset.map(tokenize, batched=True)
dataset = dataset.rename_column("label", "labels")
dataset.set_format("torch", columns=["input_ids", "attention_mask", "labels"])

model = AutoModelForSequenceClassification.from_pretrained(
    "distilroberta-base", num_labels=2
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=8,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename column text -> input_text

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -14,5 +14,5 @@
 def tokenize(examples):
     return tokenizer(
-        examples["input_text"],
+        examples["text"],
         padding="max_length",
         truncation=True,


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: dataset_drift

Broken script:
```python
"""DistilRoberta sentiment classification on 400-sample IMDB subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("imdb", split="train[:400]")
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")

def tokenize(examples):
    return tokenizer(
        examples["text"],
        padding="max_length",
        truncation=True,
        max_length=64,
    )

dataset = dataset.map(tokenize, batched=True)
dataset = dataset.rename_column("labels", "labels")
dataset.set_format("torch", columns=["input_ids", "attention_mask", "labels"])

model = AutoModelForSequenceClassification.from_pretrained(
    "distilroberta-base", num_labels=2
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=8,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename column label -> labels

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -22,5 +22,5 @@

 dataset = dataset.map(tokenize, batched=True)
-dataset = dataset.rename_column("labels", "labels")
+dataset = dataset.rename_column("label", "labels")
 dataset.set_format("torch", columns=["input_ids", "attention_mask", "labels"])


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: tokenizer_drift

Broken script:
```python
"""DistilRoberta sentiment classification on 400-sample IMDB subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("imdb", split="train[:400]")
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")

def tokenize(examples):
    return tokenizer(
        examples["text"],
        padding="max_length",
        truncate=True,
        max_length=64,
    )

dataset = dataset.map(tokenize, batched=True)
dataset = dataset.rename_column("label", "labels")
dataset.set_format("torch", columns=["input_ids", "attention_mask", "labels"])

model = AutoModelForSequenceClassification.from_pretrained(
    "distilroberta-base", num_labels=2
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=8,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change tokenizer kwarg truncation=True -> truncate=True

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -16,5 +16,5 @@
         examples["text"],
         padding="max_length",
-        truncate=True,
+        truncation=True,
         max_length=64,
     )


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""DistilRoberta sentiment classification on 400-sample IMDB subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("imdb", split="train[:400]")
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")

def tokenize(examples):
    return tokenizer(
        examples["text"],
        padding="max_length",
        truncation=True,
        max_length=64,
    )

dataset = dataset.map(tokenize, batched=True)
dataset = dataset.rename_column("label", "labels")
dataset.set_format("torch", columns=["input_ids", "attention_mask", "labels"])

model = AutoModelForSequenceClassification.from_pretrained(
    "distilroberta-base", num_labels=2
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=8,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Remove Trainer.save_model

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -41,4 +41,4 @@
 trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
 trainer.train()
-trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
+trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -51,5 +51,5 @@
     data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.load_from_hub("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.load_from_hub("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename from_pretrained -> load_from_hub

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -10,5 +10,5 @@

 dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
-tokenizer = AutoTokenizer.load_from_hub("google/flan-t5-small")
+tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

@@ -32,5 +32,5 @@
 dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

-model = AutoModelForSeq2SeqLM.load_from_hub("google/flan-t5-small")
+model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

 training_args = Seq2SeqTrainingArguments(


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change args of TrainingArguments: -num_train_epochs +max_steps

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -36,4 +36,5 @@
 training_args = Seq2SeqTrainingArguments(
     output_dir="/tmp/forge_output/checkpoint",
+    num_train_epochs=1,
     per_device_train_batch_size=4,
     logging_steps=5,


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: config_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=1,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change TrainingArguments.per_device_train_batch_size

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -37,5 +37,5 @@
     output_dir="/tmp/forge_output/checkpoint",
     num_train_epochs=1,
-    per_device_train_batch_size=1,
+    per_device_train_batch_size=4,
     logging_steps=5,
     save_strategy="epoch",


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: tokenizer_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncate=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncate=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change tokenizer kwarg truncation=True -> truncate=True

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -17,5 +17,5 @@
         ["summarize: " + a for a in examples["article"]],
         max_length=128,
-        truncate=True,
+        truncation=True,
         padding="max_length",
     )
@@ -23,5 +23,5 @@
         examples["highlights"],
         max_length=32,
-        truncate=True,
+        truncation=True,
         padding="max_length",
     )


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets["input_ids"]
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Remove Trainer.save_model

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -52,4 +52,4 @@
 )
 trainer.train()
-trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
+trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny T5 fine-tuning for summarization on 100-sample CNN/DailyMail."""
from transformers import (
    AutoTokenizer,
    AutoModelForSeq2SeqLM,
    DataCollatorForSeq2Seq,
    Seq2SeqTrainer,
    Seq2SeqTrainingArguments,
)
from datasets import load_dataset

dataset = load_dataset("cnn_dailymail", "3.0.0", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

def preprocess(examples):
    inputs = tokenizer(
        ["summarize: " + a for a in examples["article"]],
        max_length=128,
        truncation=True,
        padding="max_length",
    )
    targets = tokenizer(
        examples["highlights"],
        max_length=32,
        truncation=True,
        padding="max_length",
    )
    inputs["labels"] = targets.input_ids
    return inputs

dataset = dataset.map(preprocess, batched=True, remove_columns=dataset.column_names)

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")

training_args = Seq2SeqTrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
    predict_with_generate=False,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DataCollatorForSeq2Seq(tokenizer, model=model),
)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change return type of tokenizer

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -26,5 +26,5 @@
         padding="max_length",
     )
-    inputs["labels"] = targets.input_ids
+    inputs["labels"] = targets["input_ids"]
     return inputs


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: dataset_drift

Broken script:
```python
"""Tiny PyTorch MLP on a 1000-sample MNIST subset (image classification baseline)."""
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from datasets import load_dataset

dataset = load_dataset("mnist", split="train[:1000]")
dataset = dataset.with_format("torch")

def collate(batch):
    pixel = torch.stack([b["image"].float().flatten() / 255.0 for b in batch])
    labels = torch.tensor([b["labels"] for b in batch])
    return pixel, labels

loader = DataLoader(dataset, batch_size=32, shuffle=True, collate_fn=collate)

model = nn.Sequential(
    nn.Linear(784, 64),
    nn.ReLU(),
    nn.Linear(64, 10),
)

optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
criterion = nn.CrossEntropyLoss()

for epoch in range(2):
    for step, (x, y) in enumerate(loader, start=1):
        optimizer.zero_grad()
        loss = criterion(model(x), y)
        loss.backward()
        optimizer.step()
        if step % 5 == 0:
            print(f"step={step} loss={loss.item():.4f}")

torch.save(model.state_dict(), "/tmp/forge_output/checkpoint/mlp.pt")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename column label -> labels

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -11,5 +11,5 @@
 def collate(batch):
     pixel = torch.stack([b["image"].float().flatten() / 255.0 for b in batch])
-    labels = torch.tensor([b["labels"] for b in batch])
+    labels = torch.tensor([b["label"] for b in batch])
     return pixel, labels


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["label"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.from_pretrained(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -37,5 +37,5 @@

 trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.load_from_hub("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["label"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.load_from_hub(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename from_pretrained -> load_from_hub

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -10,5 +10,5 @@

 dataset = load_dataset("cifar10", split="train[:200]")
-processor = AutoImageProcessor.load_from_hub("WinKawaks/vit-tiny-patch16-224")
+processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

@@ -22,5 +22,5 @@
 dataset = dataset.with_transform(transform)

-model = AutoModelForImageClassification.load_from_hub(
+model = AutoModelForImageClassification.from_pretrained(
     "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
 )


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["label"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.from_pretrained(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change args of TrainingArguments: -num_train_epochs +max_steps

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -28,4 +28,5 @@
 training_args = TrainingArguments(
     output_dir="/tmp/forge_output/checkpoint",
+    num_train_epochs=1,
     per_device_train_batch_size=4,
     logging_steps=5,


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: config_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["label"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.from_pretrained(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=1,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Change TrainingArguments.per_device_train_batch_size

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -29,5 +29,5 @@
     output_dir="/tmp/forge_output/checkpoint",
     num_train_epochs=1,
-    per_device_train_batch_size=1,
+    per_device_train_batch_size=4,
     logging_steps=5,
     save_strategy="epoch",


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: dataset_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["labels"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.from_pretrained(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename column label -> labels

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -16,5 +16,5 @@
     images = [img.convert("RGB") for img in batch["img"]]
     inputs = processor(images=images, return_tensors="pt")
-    inputs["labels"] = torch.tensor(batch["labels"])
+    inputs["labels"] = torch.tensor(batch["label"])
     return inputs


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""Tiny ViT image classification on 200-sample CIFAR-10 subset."""
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification,
    Trainer,
    TrainingArguments,
)
from datasets import load_dataset
import torch

dataset = load_dataset("cifar10", split="train[:200]")
processor = AutoImageProcessor.from_pretrained("WinKawaks/vit-tiny-patch16-224")

def transform(batch):
    images = [img.convert("RGB") for img in batch["img"]]
    inputs = processor(images=images, return_tensors="pt")
    inputs["labels"] = torch.tensor(batch["label"])
    return inputs

dataset = dataset.with_transform(transform)

model = AutoModelForImageClassification.from_pretrained(
    "WinKawaks/vit-tiny-patch16-224", num_labels=10, ignore_mismatched_sizes=True
)

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
trainer.train()
trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Remove Trainer.save_model

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -38,4 +38,4 @@
 trainer = Trainer(model=model, args=training_args, train_dataset=dataset)
 trainer.train()
-trainer.save_model_DEPRECATED("/tmp/forge_output/checkpoint")
+trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")


[System]
You are the Repair Agent.
You see a broken HuggingFace training script, an error trace, and the current
library version snapshot. Output ONLY a unified diff that fixes the script.

Rules:
1. Use canonical unified-diff format with `--- a/train.py` / `+++ b/train.py`
   headers and `@@ ... @@` hunk markers.
2. Make the MINIMAL change that resolves the error AND preserves the original
   training intent. Do NOT add bare-except blocks, monkey-patches, or sys.exit
   calls.
3. Do NOT add any prose, markdown fences, or thinking output — diff only.
4. If the error is unfixable, output an empty diff.

[User]
Library versions: transformers=4.40.0, datasets=2.18.0, trl=0.10.0
Target category hint: api_drift

Broken script:
```python
"""ALBERT-tiny extractive QA on 100-sample SQuAD subset."""
from transformers import (
    AutoTokenizer,
    AutoModelForQuestionAnswering,
    Trainer,
    TrainingArguments,
    DefaultDataCollator,
)
from datasets import load_dataset

dataset = load_dataset("squad", split="train[:100]")
tokenizer = AutoTokenizer.from_pretrained("albert-base-v2")

def prepare(examples):
    enc = tokenizer(
        examples["question"],
        examples["context"],
        max_length=128,
        truncation="only_second",
        padding="max_length",
        return_offsets_mapping=True,
    )
    start_positions, end_positions = [], []
    for i, offsets in enumerate(enc["offset_mapping"]):
        answer = examples["answers"][i]
        start_char = answer["answer_start"][0]
        end_char = start_char + len(answer["text"][0])

        token_start = next(
            (idx for idx, (a, b) in enumerate(offsets) if a <= start_char < b), 0
        )
        token_end = next(
            (idx for idx, (a, b) in enumerate(offsets) if a < end_char <= b), token_start
        )
        start_positions.append(token_start)
        end_positions.append(token_end)

    enc["start_positions"] = start_positions
    enc["end_positions"] = end_positions
    enc.pop("offset_mapping")
    return enc

dataset = dataset.map(prepare, batched=True, remove_columns=dataset.column_names)

model = AutoModelForQuestionAnswering.from_pretrained("albert-base-v2")

training_args = TrainingArguments(
    output_dir="/tmp/forge_output/checkpoint",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=5,
    save_strategy="epoch",
    no_cuda=True,
    report_to="none",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset,
    data_collator=DefaultDataCollator(),
)
trainer.start_training()
trainer.save_model("/tmp/forge_output/checkpoint")
print("TRAINING_COMPLETE")

```

Error trace:
[simulated] Rename trainer.train -> trainer.start_training

Output unified diff (no prose, no fences):

[Assistant]
--- a/train.py
+++ b/train.py
@@ -63,5 +63,5 @@
     data_collator=DefaultDataCollator(),
 )
-trainer.start_training()
+trainer.train()
 trainer.save_model("/tmp/forge_output/checkpoint")
 print("TRAINING_COMPLETE")