ImportError: cannot import name 'AutoModel' from 'transformers'
Author: akeyhero
Pull request: no

# 🐛 Bug

(Not sure that it is a bug, but it is too easy to reproduce I think)

## Information

I couldn't run `python -c 'from transformers import AutoModel'`, instead getting the error on the titile.

## To reproduce

Steps to reproduce the behavior:

1. `$ sudo docker run -it --rm python:3.6 bash`
2. `# pip install tensorflow==2.0 transformers==2.8.0`
3. `# python -c 'from transformers import AutoModel'`

```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'AutoModel'
```

Initially I got this error with `transformers-cli download` :

```
# transformers-cli download t5-large
Traceback (most recent call last):
  File "/usr/local/bin/transformers-cli", line 32, in <module>
    service.run()
  File "/usr/local/lib/python3.6/site-packages/transformers/commands/download.py", line 29, in run
    from transformers import AutoModel, AutoTokenizer
ImportError: cannot import name 'AutoModel'
```

## Expected behavior

no import error.

## Environment info

- `transformers` version: 2.8.0
- Platform: Linux-4.15.0-99-generic-x86_64-with-debian-10.3
- Python version: 3.6.10
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.0.0 (False)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

Also tested on 3.6@Ubuntu 18.04, 3.8@Docker(python:3.8).
The Docker backend is Ubuntu 18.04.

Thank you.

Comments:
Got the same result with 2.9.0, i.e. with `# pip install tensorflow==2.0 transformers==2.9.0`

`AutoModel` is the equivalent of `TFAutoModel` but for PyTorch model classes. If you don't have pytorch installed this is expected.

Use `TFAutoModel` instead =)



Thank you!

@julien-c 
But there still is a problem with `transformers-cli`.
Now, people who want to use `transformers-cli download` are required to install PyTorch even when they use Tensorflow only.

edit:
It could be the problem specific to `t5-large`. I'll try it later.

I have pytorch installed but still show the error:
`ImportError: cannot import name 'AutoModelForSequenceClassification'`

Environment info:
* Ubuntu 16.04.6
* Python 3.6.8
* Torch 1.2.0
* CUDA 10.0
* transformers 4.8.2

@JTWang2000, even without PyTorch you should be able to import `AutoModelForSequenceClassification`:

```py
Python 3.8.6 (default, Dec  4 2020, 09:21:54) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
>>> from transformers import AutoModelForSequenceClassification
>>>
```

Can you offer a reproducible example? Thanks!

@LysandreJik Thank you for your reply
### Steps to reproduce the behavior:

* Python: 3.6.8
* Ubuntu 16.04.6
* CUDA 10.0
` pip install torch==1.2.0 torchvision==0.4.0`
` pip install transformers`
```
Python 3.6.8 (default, Jul  6 2021, 15:59:52)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from transformers import AutoModel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AutoModel'
>>> from transformers import AutoModelForSequenceClassification
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AutoModelForSequenceClassification'
```

The may be som error as I am getting:

```
Traceback (most recent call last):
  File "/home/usename/dev/speech_recognition.py", line 1, in <module>
    from transformers import Wav2Vec2Tokenizer, Wav2Vec2ForCTC
ImportError: cannot import name 'Wav2Vec2ForCTC' from 'transformers' (unknown location)
```

The line of code: 

```
from transformers import Wav2Vec2Tokenizer, Wav2Vec2ForCTC
```

Transformers: 4.3.0
Python 3.9.6
OS: Fedora 34

@JTWang2000 Recent versions of `transformers` are compatible with more recent PyTorch versions, see the [README](https://github.com/huggingface/transformers#with-pip).

@kennylajara could you try upgrading `transformers` to a more recent version to see if it fixes your issue? (Wav2Vec2 has been improved since v4.3.0) - if not, do you mind linking me to a reproducible code example (with pip installations)/colab notebook or something similar that reproduces your issue?

**EDIT:** Well... **This** issue has been solved by updating dependencies but now it produces another issue. I will post the link to the reproducible issue in a minute.

@LysandreJik There you go: [https://github.com/kennylajara/speech-recognition](https://github.com/kennylajara/speech-recognition)

@LysandreJik Thank you for the reply.
I reinstall PyTorch with version 1.7.0 and now it works. Thanks! 

@kennylajara answered in a separate issue (please keep issues on different subjects separate, thank you): https://github.com/kennylajara/speech-recognition/issues/1

In my case I both installed pytorch and tensorflow (noob). Creating new environment just for pytorch help me solve it.