code: def download_url(
      url: str, root: Path, filename: Optional[str] = None
  ) -> Path:
      """Download a file from a url and place it in root.
      Args:
          url (str): URL to download file from
          root (str): Directory to place downloaded file in
          filename (str): Name to save the file under.
                          If None, use the basename of the URL
      """
  
      root = root.expanduser()
      if filename is None:
          filename = Path(urlparse(url).path).name
      fpath = root / filename
      if not root.exists():
          root.mkdir(parents=True, exist_ok=True)
  
      # downloads file
      if fpath.is_file():
          print(f"Using downloaded and verified file: {fpath}")
      else:
          try:
              print(f"Downloading {url} to {fpath}")
              urlretrieve(
                  url,
                  str(fpath),
                  reporthook=gen_bar_updater(
                      tqdm(unit="B", unit_scale=True)
                  ),
              )
          except OSError:
              print(f"Failed to download from url: {url}")
  
      return fpath
  
file_path: PyTorch-BigGraph/torchbiggraph/converters/utils.py
imports: import gzip
  import shutil
  import tarfile
  from pathlib import Path
  from typing import Callable, Optional
  from urllib.parse import urlparse
  from urllib.request import urlretrieve
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: download_url(url, root, filename) and returns: fpath