trainer.save_model   load error 
reference code : https://github.com/bhadreshpsavani/UnderstandingNLP/blob/master/go_emotion_of_transformers_multilabel_text_classification_v2.ipynb

----
----> 6 save_model ='./model/emotion'
----> 7 trainer.save_model(save_model)
----> 8 load_model = AutoModel.from_pretrained(save_model)

4 frames
[/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py](https://localhost:8080/#) in __init__(self, **kwargs)
    315                     f"{self.id2label}. The number of labels wil be overwritten to {self.num_labels}."
    316                 )
--> 317             print(id2label)
    318             self.id2label = dict((int(key), value) for key, value in self.id2label.items())
    319             # Keys are always strings in JSON so convert ids to int here.

AttributeError: 'list' object has no attribute 'items'


---

After fine-tuning the emotion classification model with 28 classes, I learned and saved it through trainer() , but the model is not loaded. can someone help?

Please use the [forums](https://discuss.huggingface.co/) to help debug your code. Happy to help here when you have a short reproducer, but otherwise we keep issues for bugs and feature requests only.<|||||>Hi @oosij, this is a very annoying issue from the HF implementation of the id2label management. The model will load correctly if id2label is provided as a dict when you specify the model before fine-tuning. Providing id2label in a form of a list causes no trouble during training / inference until you try to restore the fine-tuned model.

Consider something like this:
```python
id2label = {i: e for i, e in enumerate(tags)}
label2id = {e: i for i, e in enumerate(tags)}

log.info('Loading pre-trained checkpoint of a model...')
tokenizer = AutoTokenizer.from_pretrained(config.model.checkpoint, add_prefix_space=True)
model = AutoModelForTokenClassification.from_pretrained(
    config.model.checkpoint,
    id2label=id2label,
    label2id=label2id,
)

# ... fine-tune the model

trainer.save_model(config.training.save_path)
debug = AutoModelForTokenClassification.from_pretrained(config.training.save_path) # This will work now
```<|||||>@IINemo Would you like to make a PR adding a sanity check that immediately raises an error if the user tries to provide label2id/id2label that are lists instead of dictionaries?<|||||>@sgugger Ok, give me some time.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.