Repository: pytorch
Issue: ImportError: cannot import name '_VF' from partially initialized module 'torch'
Labels: needs reproduction,low priority,triaged

### 🐛 Describe the bug

I receive an ImportError when I try to execute a cx-freezed script which contains a torch import.

Script for reproduction:

```python
# prepare script
test_dir=/tmp/test
mkdir --p $test_dir
cat > $test_dir/script.py << EOF
import torch
EOF

# create pipenv
cd $test_dir
pipenv install --python 3.8
pipenv install torch
pipenv install cx-freeze --dev

# freeze
mkdir -p $test_dir/dist
pipenv run cxfreeze \
  -O \
  --compress \
  --target-dir=$test_dir/dist \
  --target-name="script" \
  $test_dir/script.py

# run
$test_dir/dist/script
```

Output:

```
Traceback (most recent call last):
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/cx_Freeze/initscripts/__startup__.py", line 113, in run
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/cx_Freeze/initscripts/Console.py", line 15, in run
  File "/tmp/test/script.py", line 1, in <module>
    import torch
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/__init__.py", line 643, in <module>
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/functional.py", line 6, in <module>
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/nn/modules/__init__.py", line 2, in <module>
    from .linear import Identity, Linear, Bilinear, LazyLinear
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 6, in <module>
    from .. import functional as F
  File "/home/mi/.local/share/virtualenvs/test-hxkKlP5o/lib/python3.8/site-packages/torch/nn/functional.py", line 7, in <module>
    from torch import _VF
ImportError: cannot import name '_VF' from partially initialized module 'torch' (most likely due to a circular import) (/tmp/test/dist/lib/torch/__init__.pyc)
```

Additional info:

`pipenv --version`
Output: 

```
pipenv, version 2020.11.15
```

`cat Pipfile.lock`

Output:

```json
{
    "_meta": {
        "hash": {
            "sha256": "0f0da7de028165614f3778a604a14d5132675fa4f23311a0c341b8404c16afb9"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.8"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "torch": {
            "hashes": [
                "sha256:258a0729fb77a3457d5822d84b536057cd119b08049a8d3c41dc3dcdeb48d56e",
                "sha256:3592d3dd62b32760c82624e7586222747fe2281240e8653970b35f1d6d4a434c",
                "sha256:376fc18407add20daa6bbaaffc5a5e06d733abe53bcbd60ef2532bfed34bc091",
                "sha256:3eee3cf53c1f8fb3f1fe107a22025a8501fc6440d14e09599ba7153002531f84",
                "sha256:5b68e9108bd7ebd99eee941686046c517cfaac5331f757bcf440fe02f2e3ced1",
                "sha256:65fd02ed889c63fd82bf1a440c5a94c1310c29f3e6f9f62add416d34da355d97",
                "sha256:6a81f886823bbd15edc2dc0908fa214070df61c9f7ab8831f0a03630275cca5a",
                "sha256:6da1b877880435440a5aa9678ef0f01986d4886416844db1d97ebfb7fd1778d0",
                "sha256:8f3fd2e3ffc3bb867133fdf7fbcc8a0bb2e62a5c0696396f51856f5abf9045a8",
                "sha256:901b52787baeb2e9e1357ca7037da0028bc6ad743f530e0040ae96ef8e27156c",
                "sha256:935e5ac804c5093c79f23a7e6ca5b912c166071aa9d8b4a0a3d6a85126d6a47b",
                "sha256:97b7b0c667e8b0dd1fc70137a36e0a4841ec10ef850bda60500ad066bef3e2de",
                "sha256:9ef4c004f9e5168bd1c1930c6aff25fed5b097de81db6271ffbb2e4fb8b89319",
                "sha256:ab77a9f838874f295ed5410c0686fa22547456e0116efb281c66ef5f9d46fe28",
                "sha256:b07ef01e36b716d0d65ca60c4db0ac9d094a0e797d9b55290da4dcda91463b6c",
                "sha256:d43bc3f3a2d89ae185ef96d903c935c335219231e57685658648396984e2a67a",
                "sha256:ef99b8cca5f9358119b07956915faf6e7906f433ab4a603c160ae9de88918371",
                "sha256:f281438ee99bd72ad65c0bba1026a32e45c3b636bc067fc145ad291e9ea2faab",
                "sha256:fbaf18c1b3e0b31af194a9d853e3739464cf982d279df9d34dd18f1c2a471878"
            ],
            "index": "pypi",
            "version": "==1.10.2"
        },
        "typing-extensions": {
            "hashes": [
                "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e",
                "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"
            ],
            "markers": "python_version >= '3.6'",
            "version": "==4.0.1"
        }
    },
    "develop": {
        "cx-freeze": {
            "hashes": [
                "sha256:08a537681dcd1bcde9742584e91d86ef001fe798386f2834a904652d5b2a468a",
                "sha256:1438db6d59be86e8483ea2bf2ff2f81374ca63d8a1d3a84706173cc1b98dd46f",
                "sha256:2be07ffce2dba23618cf736476df6f9837d9887c85f4f92fb3fbfcd090de041a",
                "sha256:59b4cb77f5c82613efbec03815b952a6fe73d4a1805bb370d57a8a1130a181ca",
                "sha256:770e911f70b48e4f309a47e02aaa7e1f6dc659fd1c486f3eebe5c9e9fe70aec2",
                "sha256:8d936a872c124c2e2a40da2e898e4fa0d225a165ab606217f75136c14ee8e673",
                "sha256:9c4b491affd10065bcdd20dc0ab5239f787affe6d61857811a937ed266faa213",
                "sha256:a4d2cb00eec6bc72a419370b5b0b5d0f3adf4d8417eb89228981d470cf4c6af6",
                "sha256:e5b71bf57b9881ac142fbebeae2c8b0d3294b56f6e48ab64032321e3b1a2ba27",
                "sha256:ec752333fa2e40347902730662785da0ec4576cec976552784a6f60a7a07b45d",
                "sha256:f03928cbcf8282e688dc1f9fa421044c24f5b7492a7b0fe7f45d5cc6f24c1ebf"
            ],
            "index": "pypi",
            "version": "==6.10"
        },
        "importlib-metadata": {
            "hashes": [
                "sha256:899e2a40a8c4a1aec681feef45733de8a6c58f3f6a0dbed2eb6574b4387a77b6",
                "sha256:951f0d8a5b7260e9db5e41d429285b5f451e928479f19d80818878527d36e95e"
            ],
            "markers": "python_version < '3.10'",
            "version": "==4.10.1"
        },
        "patchelf": {
            "hashes": [
                "sha256:04cdeea7b24d8daca78e885a113791cedb278eb164a1760c509702d6ed155a46",
                "sha256:09ad55d9dff020ecab75d02ae592b6ff7997fc0428ce7ffb35213b3fdd79dad7",
                "sha256:0c778f7af59bd781d187ea27556a1ad3e0dd044d85c77536a7c9d2cc027ff0fc",
                "sha256:4b3ee96c6ac9b2059f038db2838bc0be4d119d3b5b8b0cc252e5cadd832a5ae5",
                "sha256:a8dd89901f32f0ce93a5c995a8f9eb79908d43e3a70eaf6b8efe8643976e6a8c",
                "sha256:fa208aee4b0e6b3f4dbd1bb2be82b1d2635e045e7dfe227b2095bb2e3db67811"
            ],
            "markers": "sys_platform == 'linux'",
            "version": "==0.14.3.0"
        },
        "wheel": {
            "hashes": [
                "sha256:4bdcd7d840138086126cd09254dc6195fb4fc6f01c050a1d7236f2630db1d22a",
                "sha256:e9a504e793efbca1b8e0e9cb979a249cf4a0a7b5b8c9e8b65a5e39d49529c1c4"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
            "version": "==0.37.1"
        },
        "zipp": {
            "hashes": [
                "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d",
                "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"
            ],
            "markers": "python_version >= '3.7'",
            "version": "==3.7.0"
        }
    }
}
```

### Versions

```sh
cd $test_dir
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
pipenv shell
python collect_env.py
```

Output:

```
Collecting environment information...
Traceback (most recent call last):
  File "collect_env.py", line 469, in <module>
    main()
  File "collect_env.py", line 452, in main
    output = get_pretty_env_info()
  File "collect_env.py", line 447, in get_pretty_env_info
    return pretty_str(get_env_info())
  File "collect_env.py", line 301, in get_env_info
    version_str = torch.__version__
AttributeError: module 'torch' has no attribute '__version__'
```