code: def validate_file(download_url, download_path):
      """
      Validate the downloaded file and resume the download if needed.
  
      Arguments
      ---------
      download_url : str
          URL of the file being downloaded
      download_path : str
          Full path of the file that is to be downloaded
          (or already downloaded)
  
      Returns
      -------
      bool
          If True, the file need not be downloaded again.
          Else, either the file is not yet downloaded or
          partially downloaded, thus resume the download.
      """
      if not os.path.isfile(download_path):
          # File not yet downloaded
          return False
  
      # Get file size in MB
      actual_size = urllib.request.urlopen(
          download_url,
          context=ssl.create_default_context(cafile=certifi.where()),
      ).length
  
      download_size = os.path.getsize(download_path)
  
      print(
          "File: {}, \t downloaded {} MB out of {} MB".format(
              download_path.split("/")[-1],
              download_size // (1024 * 1024),
              actual_size // (1024 * 1024),
          ),
          end="",
      )
      # Set a margin of 100 MB. We skip re-downloading the file if downloaded
      # size differs from actual size by max 100 MB. More than this margin,
      # re-download is to attempted.
      if actual_size - download_size < 100 * 1024 * 1024:
          return True
      else:
          print(", \tIncomplete download. Resuming...")
          return False
  
file_path: speechbrain/recipes/DNS/dns_download.py
imports: import os
  import ssl
  import shutil
  import zipfile
  import tarfile
  import certifi
  import argparse
  import fileinput
  import requests
  import urllib.request
  from tqdm.auto import tqdm
  from concurrent.futures import ThreadPoolExecutor
label_desc: Use image node_id 8 for calling a global function with example usage: validate_file(download_url, download_path) and returns: False, True, False