Your 1.7.0dev result is as expected (torch 1.5.0 and above produce [1, 10, 30, 30]).
The following works for me for installing 1.4.0:
virtualenv -p python3 venv/
source venv/bin/activate
pip install torch==1.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
python /path/to/repro.py