HF space specific issue: can't import `AutoModelForSeq2SeqLM` from `transformers==4.6.1` with `torch` installed
Author: aseifert
Pull request: no

For some reason I can't import `AutoModelForSeq2SeqLM` when running on hf space AND having installed `torch==1.10.0`.

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.6.1
- Platform: HF Space – https://huggingface.co/spaces/aseifert/AutoModelForSeq2SeqLM-not-working
- Python version: 3.8
- PyTorch version (GPU?): 1.10.0
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- encoder-decoder models (For example, BlenderBot, BART, Marian, Pegasus, T5, ByT5): @patrickvonplaten, @patil-suraj
- Longformer, Reformer, TransfoXL, XLNet, FNet: @patrickvonplaten
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj @patrickvonplaten 
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten
- Tokenizers: @LysandreJik
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## To reproduce

Here is a minimal example illustrating the problem, with the only difference being the installation of `torch` through `requirements.txt`:

Works: https://huggingface.co/spaces/aseifert/AutoModelForSeq2SeqLM-working
Doesn't work: https://huggingface.co/spaces/aseifert/AutoModelForSeq2SeqLM-not-working

As far as I can tell this only happens on HF Space. I can't reproduce the problem on Google Colab: https://colab.research.google.com/drive/1SfNk-YjwqxYC_92y-652NoYrCi-vBEHd?usp=sharing

Not sure what's happening here, hopefully someone can help me figure this out!

Thanks,
Alex


Comments:
cc @cbensimon 

Thank you for flagging this issue @aseifert ! 

~I was able to reproduce this locally in `conda` using:~

```
conda create -n buggy-space python=3.8 && conda activate bugg-space
pip install transformers==4.6.1 torch==1.10.0
```

~followed by running the following inside the Python repl:~

```
from transformers import AutoModelSeq2SeqLM
```

~The _really_ strange aspect is that the following runs without error:~

```
python -c "from transformers import AutoModelSeq2SeqLM"
```

~I was also able to reproduce the error up to `transformers` v4.8, after which the `AutoModelSeeq2SeqLM` class was replaced separate classes for encoder / decoder LM.~

~I'm not entirely sure what is causing the problem here, but don't think it's specifically connected to Spaces~

Edit: the above is not true because of a typo in the import 🙈 . Using `AutoModelForSeq2SeqLM` works fine locally, so the problem does indeed appear to reside on the Spaces side

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/master/CONTRIBUTING.md) are likely to be ignored.