[TorchHub]Repo's layout is not compatible with TorchHub anymore since 2.0
Author: chenliu0831
Pull request: no
Labels: name: wontfix

# 🐛 Bug

When I try loading a model/tokenizer from the [pytorch hub](https://pytorch.org/hub/huggingface_pytorch-transformers/) page, the hub loading code is not working anymore. Pre transformers 2.0.0, the same loading code is working.

On a quick look, I believe it's related to the repo's fold layout since 2.0 where the `transformers` module is moved inside `src` but `hub_conf` is still assuming `transformers` exists in the same level and we get a module not found error.  For context, torch hub insert the repo root directory into `sys.path` to enable import.

## To reproduce

Run
```
import torch
tokenizer = torch.hub.load('huggingface/transformers:v2.5.0', 'tokenizer', 'bert-base-cased')
```
Stack trace:

```
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-155f4aa294f1> in <module>
      1 import torch
----> 2 tokenizer = torch.hub.load('huggingface/transformers:v2.5.0', 'tokenizer', 'bert-base-cased')
      3 
      4 text_1 = "Who was Jim Henson ?"
      5 text_2 = "Jim Henson was a puppeteer"

~/miniconda3/envs/poc/lib/python3.7/site-packages/torch/hub.py in load(github, model, *args, **kwargs)
    354     sys.path.insert(0, repo_dir)
    355 
--> 356     hub_module = import_module(MODULE_HUBCONF, repo_dir + '/' + MODULE_HUBCONF)
    357 
    358     entry = _load_entry_from_hubconf(hub_module, model)

~/miniconda3/envs/poc/lib/python3.7/site-packages/torch/hub.py in import_module(name, path)
     70         spec = importlib.util.spec_from_file_location(name, path)
     71         module = importlib.util.module_from_spec(spec)
---> 72         spec.loader.exec_module(module)
     73         return module
     74     elif sys.version_info >= (3, 0):

~/miniconda3/envs/poc/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module)

~/miniconda3/envs/poc/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/.cache/torch/hub/huggingface_transformers_v2.5.0/hubconf.py in <module>
----> 1 from transformers import (
      2     AutoConfig,
      3     AutoModel,
      4     AutoModelForQuestionAnswering,
      5     AutoModelForSequenceClassification,

ModuleNotFoundError: No module named 'transformers'
```

## Expected behavior

This was working before 2.0.0. 

```
import torch
tokenizer = torch.hub.load('huggingface/transformers:1.2.0', 'tokenizer', 'bert-base-cased')

```

## Environment info
     
- `transformers` version: >2.0.0
- Platform: all
- Python version: 3.7
- PyTorch version (GPU?): 1.3.1
- Tensorflow version (GPU?): N/A
- Using GPU in script?: N/A
- Using distributed or parallel set-up in script?: N/A


Comments:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


Any plan to fix this?

I missed that issue, but this was fixed a couple of weeks ago, and it's even covered by CI now: https://github.com/huggingface/transformers/blob/master/.github/workflows/github-torch-hub.yml