TypeError: on_init_end() got an unexpected keyword argument 'model'
Author: MiriamFarber
Pull request: no
Labels: name: wontfix

## Environment info

- `transformers` version: 4.0.0
- Python 3.6.10
- Pytorch version: 1.6.0
- pytorch-lightning version: 1.0.3

I'm using aws_neuron_pytorch_p36 virtual environment (on p3 ec2 instance). Regarding pytorch-lightning version, the above version is the highest one I can currently use (higher versions are not supported in my framework)

### Who can help
@LysandreJik
@sgugger

## Information

Model I am using RobertaForSequenceClassification


## To reproduce

The code I'm running:

```
from transformers import RobertaForSequenceClassification
from transformers import Trainer, TrainingArguments

from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning import metrics

model = RobertaForSequenceClassification.from_pretrained(
                self.training_configuration.hyper_params.pretrained_model_path, num_labels=2)

model_checkpoint = ModelCheckpoint(filepath = model_path,
                                           verbose=1,
                                           save_top_k=1,
                                           save_weights_only=True,
                                           monitor=self.training_configuration.monitor,
                                           mode=self.training_configuration.monitor_mode,
                                           period=1)
  
early_stopping = EarlyStopping(monitor=self.training_configuration.monitor,
                                       patience=self.training_configuration.patience,
                                       mode=self.training_configuration.monitor_mode)


training_args = TrainingArguments(
            output_dir=os.path.dirname(model_path),  # output directory
            evaluation_strategy="epoch",  # Evaluation is done at the end of each epoch.
            num_train_epochs=self.training_configuration.epoch,  # total number of training epochs
            per_device_train_batch_size=self.training_configuration.batch_size,  # batch size per device during training
            per_device_eval_batch_size=self.training_configuration.batch_size,  # batch size for evaluation
            warmup_steps=warmup_steps,  # number of warmup steps for learning rate scheduler
            weight_decay=self.training_configuration.hyper_params.weight_decay,  # strength of weight decay
            save_total_limit=1,  # limit the total amount of checkpoints. Deletes the older checkpoints.
        )

trainer = Trainer(
            model=model,  # the instantiated 🤗 Transformers model to be trained
            args=training_args,  # training arguments, defined above
            train_dataset=training_data,  # training dataset
            eval_dataset=validation_data,  # evaluation dataset
            callbacks=[early_stopping, model_checkpoint],
            compute_metrics = metrics.classification.Accuracy()
        )

trainer.train()
```

The error I'm getting:

```
    compute_metrics = metrics.classification.Accuracy()
  File "/home/ec2-user/anaconda3/envs/aws_neuron_pytorch_p36/lib/python3.6/site-packages/transformers/trainer.py", line 305, in __init__
    self.control = self.callback_handler.on_init_end(self.args, self.state, self.control)
  File "/home/ec2-user/anaconda3/envs/aws_neuron_pytorch_p36/lib/python3.6/site-packages/transformers/trainer_callback.py", line 331, in on_init_end
    return self.call_event("on_init_end", args, state, control)
  File "/home/ec2-user/anaconda3/envs/aws_neuron_pytorch_p36/lib/python3.6/site-packages/transformers/trainer_callback.py", line 382, in call_event
    **kwargs,
TypeError: on_init_end() got an unexpected keyword argument 'model'
```


Comments:
You are using a pytorch lightning callback instead of a Hugging Face `TrainerCallback`, I'm unsure of why you would think this will work. If you want to use pytorch ligthning, you will have to user their `Trainer` as well.

thanks @sgugger . The reason I used pytorch lightning callback is because I couldn't find in transformers something that saves only the best checkpoint. Is there something like that? (which I can use instead of using pytorch-lightings- ModelCheckpoint)

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.

> You are using a pytorch lightning callback instead of a Hugging Face `TrainerCallback`, I'm unsure of why you would think this will work. If you want to use pytorch ligthning, you will have to user their `Trainer` as well.

Super Helpful