<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download_tf_release(version, versions_dir, command_suffix, tf_platform=None, arch=None):
 """Download Terraform archive and return path to it."""

    version_dir = os.path.join(versions_dir, version)

    if arch is None:
        arch = (
            os.environ.get('TFENV_ARCH') if os.environ.get('TFENV_ARCH')
            else 'amd64')

    if tf_platform:
        tfver_os = tf_platform + '_' + arch
    else:
        if platform.system().startswith('Darwin'):
            tfver_os = "darwin_%s" % arch
        elif platform.system().startswith('MINGW64') or (
                platform.system().startswith('MSYS_NT') or (
                    platform.system().startswith('CYGWIN_NT'))):
            tfver_os = "windows_%s" % arch
        else:
            tfver_os = "linux_%s" % arch

    download_dir = tempfile.mkdtemp()
    filename = "terraform_%s_%s.zip" % (version, tfver_os)
    shasums_name = "terraform_%s_SHA256SUMS" % version
    tf_url = "https://releases.hashicorp.com/terraform/" + version

    for i in [filename, shasums_name]:
        urlretrieve(tf_url + '/' + i,
                    os.path.join(download_dir, i))

    tf_hash = get_hash_for_filename(filename, os.path.join(download_dir,
                                                           shasums_name))
    if tf_hash != sha256sum(os.path.join(download_dir, filename)):
        LOGGER.error("Downloaded Terraform %s does not match sha256 %s",
                     filename, tf_hash)
        sys.exit(1)

    tf_zipfile = zipfile.ZipFile(os.path.join(download_dir, filename))
    os.mkdir(version_dir)
    tf_zipfile.extractall(version_dir)
    tf_zipfile.close()
    shutil.rmtree(download_dir)
    os.chmod(  # ensure it is executable
        os.path.join(version_dir,
                     'terraform' + command_suffix),
        os.stat(os.path.join(version_dir,
                             'terraform' + command_suffix)).st_mode | 0o0111
    )