Add support for resumable downloads for HTTP protocol.
Author: sergei-mironov
Pull request: yes

Hi. This PR adds support for resumable downloads for HTTP protocol (`resume_download` flag, disabled by default). It solved my problems with unreliable network connection and may also prevent issues like 

* https://github.com/huggingface/transformers/issues/985
* https://github.com/huggingface/transformers/issues/1303
* https://github.com/huggingface/transformers/issues/1423

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=h1) Report
> Merging [#1624](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/10bd1ddb39235b2f58594e48867595e7d38cd619?src=pr&el=desc) will **increase** coverage by `27.37%`.
> The diff coverage is `67.56%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/1624/graphs/tree.svg?width=650&token=9qOlN6Hb1c&height=150&src=pr)](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master    #1624       +/-   ##
===========================================
+ Coverage   56.21%   83.58%   +27.37%     
===========================================
  Files         105      105               
  Lines       15507    15528       +21     
===========================================
+ Hits         8717    12979     +4262     
+ Misses       6790     2549     -4241
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [transformers/configuration\_auto.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2NvbmZpZ3VyYXRpb25fYXV0by5weQ==) | `59.45% <ø> (+13.51%)` | :arrow_up: |
| [transformers/modeling\_auto.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX2F1dG8ucHk=) | `31.81% <ø> (ø)` | :arrow_up: |
| [transformers/tokenization\_auto.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rva2VuaXphdGlvbl9hdXRvLnB5) | `45.94% <ø> (ø)` | :arrow_up: |
| [transformers/modeling\_tf\_auto.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX2F1dG8ucHk=) | `51.25% <ø> (+51.25%)` | :arrow_up: |
| [transformers/tokenization\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rva2VuaXphdGlvbl91dGlscy5weQ==) | `92.23% <100%> (+0.24%)` | :arrow_up: |
| [transformers/configuration\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2NvbmZpZ3VyYXRpb25fdXRpbHMucHk=) | `92.2% <100%> (+4.04%)` | :arrow_up: |
| [transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX3V0aWxzLnB5) | `92.72% <100%> (+92.72%)` | :arrow_up: |
| [transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3V0aWxzLnB5) | `89.45% <100%> (+0.02%)` | :arrow_up: |
| [transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2ZpbGVfdXRpbHMucHk=) | `66.5% <58.62%> (-5.48%)` | :arrow_down: |
| [transformers/tokenization\_albert.py](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rva2VuaXphdGlvbl9hbGJlcnQucHk=) | `82.9% <0%> (-6.84%)` | :arrow_down: |
| ... and [41 more](https://codecov.io/gh/huggingface/transformers/pull/1624/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=footer). Last update [10bd1dd...5340d1f](https://codecov.io/gh/huggingface/transformers/pull/1624?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Hi @grwlf, that's a nice addition. Do you think you could add the new arguments in the `from_pretrained` methods calling `cached_path` (and their docstrings)?

> Hi @grwlf, that's a nice addition. Do you think you could add the new arguments in the `from_pretrained` methods calling `cached_path` (and their docstrings)?

Sure. I've redesigned the solution. Now if users pass `resume_download=True`, the downloader explicitly stores the data in a file with '.incomplete' suffix, and reads it if it already exists.

This version currently doesn't protect us from strange and rare network situations where the connection is broken, but `request.get` thinks that download is completed normally. For this case I think that request handling code should be patched somehow.

But I hope that most network problems really end with an exception and that is the case which should be handled now. 

Ok great, merging!