code: def extract_data_from_tar(
      test_dir, test_data_archive, url=None, local_data=False
  ):
      # Remove .data folder.
      if exists(test_dir):
          if not local_data:
              rmtree(test_dir)
          else:
              with tempfile.TemporaryDirectory() as temp_dir:
                  print("Copying local tarfile to temporary storage..")
                  shutil.copy2(test_data_archive, temp_dir)
                  print("Deleting test dir to cleanup old data")
                  rmtree(test_dir)
                  mkdir(test_dir)
                  print("Restoring local tarfile to test dir")
                  shutil.copy2(
                      os.path.join(
                          temp_dir, os.path.basename(test_data_archive)
                      ),
                      test_data_archive,
                  )
  
      # Create one .data folder.
      if not exists(test_dir):
          mkdir(test_dir)
  
      # Download (if required)
      if url is not None and not local_data:
          urllib.request.urlretrieve(url, test_data_archive)
  
      # Extract tar
      print(
          "Extracting the `{}` test archive, please wait...".format(
              test_data_archive
          )
      )
      tar = tarfile.open(test_data_archive)
      tar.extractall(path=test_dir)
      tar.close()
  
imports: import logging
  import os.path
  import shutil
  import tarfile
  import tempfile
  import urllib.request
  from os import mkdir
  from os.path import dirname, exists, getsize, join
  from pathlib import Path
  from shutil import rmtree
  from typing import Tuple
  import pytest
  from tests.fixtures.tts import *
label_desc: Use image node_id 8 for calling a global function with example usage: extract_data_from_tar(test_dir, test_data_archive, url, local_data) without return types