def download_file(from_url, to_filename=None,<EOL>chunk_size=<NUM_LIT> * <NUM_LIT:8>, retry_count=<NUM_LIT:3>):
if not to_filename:<EOL><INDENT>to_filename = get_temporary_file()<EOL><DEDENT>session = requests.Session()<EOL>adapter = requests.adapters.HTTPAdapter(max_retries=retry_count)<EOL>session.mount(from_url, adapter)<EOL>response = session.get(from_url, stream=True)<EOL>with open(to_filename, '<STR_LIT:wb>') as fd:<EOL><INDENT>for chunk in response.iter_content(chunk_size):<EOL><INDENT>fd.write(chunk)<EOL><DEDENT><DEDENT>return to_filename<EOL>
Download URL to a file.