Not able to import T5WithLMHeadModel library from transformers
Author: SameepPanigrahi
Pull request: no

### System Info

transformers version :- 4.31.0
Python version :- 3.10

### Who can help?

@gante @ArthurZucker @sgugger 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

import transformers
from transformers import AutoConfig
model_detail = AutoConfig.from_pretrained("t5-3b")
model_library_name = model_detail.to_dict()["architectures"][0]
model_library = getattr(transformers, model_library_name)

### Expected behavior

It should able to load the T5WithLMHeadModel library from the transformers . Currently its giving me 
AttributeError: module transformers has no attribute T5WithLMHeadModel

Comments:
Hey! This model is very very old, and the `T5WithLMHeadModel` was renamed to `T5ForConditionalGeneration`, but for backward compatibility it's not the case here. Now if you want to load a model you should be using `AutoModel` and not the shared script. 

Hi I have tried with the AutoModel to load the "t5-3b" library. Its able to load the model successfully but in our case we are using pipeline for the model inference. So while doing the inference I am getting the below error. Can you please suggest an approach to make the code up and running 
Attaching the code for your reference

from transformers import AutoModel, AutoTokenizer, pipeline
import transformers
model = AutoModel.from_pretrained("t5-3b")
tokenizer = AutoTokenizer.from_pretrained("t5-3b")
pipeline = pipeline(task="translation", model=model, tokenizer=tokenizer)
pipeline("Make an offer")

Getting the below error while using this 
TypeError: The current model class (T5Model) is not compatible with `.generate()`


Hey @SameepPanigrahi 👋 

When you come across basic usage issues, try to check the [model card](https://huggingface.co/t5-3b) and, if it is a `transformers` model, the [model doc page](https://huggingface.co/docs/transformers/model_doc/t5#t5). Check the examples -- there you will find the information you need to use the model.

(I'm intentionally not giving the answer here, since GitHub issues should only be used after some exploration on the user end :) )

Hi @gante 
I am trying to run 40 different model for different task from a single code script which I have created. So for that I am trying to load the library from which I need to load the  model with this

model_detail = AutoConfig.from_pretrained("t5-3b")
model_library_name = model_detail.to_dict()["architectures"][0]
model_library = getattr(transformers, model_library_name)

then I am loading the model with the help of the model_library and doing a local inference using the pipeline .  Maximum number of models are working with this approach but for t5-3b its failing . If its a single model then I can use the example mentioned the documentation page but in my case I have to run 40 model with the same code . So in such cases can you please suggest an approach to make this t5-3b model success 

That field in the config holds the class that was used at model save time, so it might get stale. Ideally, that same class would load the model, as you're trying to do. However, we don't have a solution that programmatically solves all cases at load time.

An alternative could be some form of custom if/else, based on the Hub tags, if using the original class fails. E.g. `t5-3b` has the `text2text-generation` tag, which means the `AutoModelForSeq2Seq` class should be able to load it correctly.