code: def download_data(
      url: str,
      path: str = "data/",
      verbose: bool = False,
      chunk_size: int = 1024,
  ) -> None:
      """Download file with progressbar.
  
      # Code adapted from: https://gist.github.com/ruxi/5d6803c116ec1130d484a4ab8c00c603
      # __author__  = "github.com/ruxi"
      # __license__ = "MIT"
  
      Examples
      ________
  
      .. doctest::
  
          >>> import os
          >>> from flash.core.data.utils import download_data
          >>> download_data("https://pl-flash-data.s3.amazonaws.com/titanic.zip", "./data")
          >>> os.listdir("./data")  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
          [...]
  
      """
      local_filename = os.path.join(path, url.split("/")[-1])
      if os.path.exists(local_filename):
          if verbose:
              print(f"local file already exists: '{local_filename}'")
          return
  
      os.makedirs(path, exist_ok=True)
      # Disable warning about making an insecure request
      urllib3.disable_warnings(
          urllib3.exceptions.InsecureRequestWarning
      )
  
      r = requests.get(url, stream=True, verify=False)
      file_size = (
          int(r.headers["Content-Length"])
          if "Content-Length" in r.headers
          else 0
      )
      num_bars = int(file_size / chunk_size)
      if verbose:
          print(f"file size: {file_size}")
          print(f"num bars: {num_bars}")
  
      with open(local_filename, "wb") as fp:
          for chunk in tq(
              r.iter_content(chunk_size=chunk_size),
              total=num_bars,
              unit="KB",
              desc=local_filename,
              leave=True,  # progressbar stays
          ):
              fp.write(chunk)  # type: ignore
  
      def extract_tarfile(
          file_path: str, extract_path: str, mode: str
      ) -> None:
          if not os.path.exists(file_path):
              return
          with tarfile.open(file_path, mode=mode) as tar_ref:
              for member in tar_ref.getmembers():
                  try:
                      tar_ref.extract(
                          member, path=extract_path, set_attrs=False
                      )
                  except PermissionError:
                      raise PermissionError(
                          f"Could not extract tar file {file_path}"
                      )
  
      if ".zip" in local_filename:
          if os.path.exists(local_filename):
              with zipfile.ZipFile(local_filename, "r") as zip_ref:
                  zip_ref.extractall(path)
      elif local_filename.endswith(
          ".tar.gz"
      ) or local_filename.endswith(".tgz"):
          extract_tarfile(local_filename, path, "r:gz")
      elif local_filename.endswith(
          ".tar.bz2"
      ) or local_filename.endswith(".tbz"):
          extract_tarfile(local_filename, path, "r:bz2")
  
file_path: lightning-flash/src/flash/core/data/utils.py
imports: import os.path
  import tarfile
  import zipfile
  from typing import Any, Callable, Dict, Iterable, Mapping, Optional, Set
  import requests
  import urllib3
  from pytorch_lightning.utilities.apply_func import apply_to_collection
  from torch import nn
  from tqdm.auto import tqdm
  from flash.core.utilities.imports import _TOPIC_CORE_AVAILABLE
  from flash.core.utilities.stages import RunningStage
label_desc: Use image node_id 1 for calling a global function with example usage: download_data(url, path, verbose, chunk_size) without return types