code: def _extract(directory: str, filename: str) -> str:
      file_path = os.path.join(directory, filename)
      extracted_folder = filename.rsplit(".", 1)[0]
      extracted_folder = os.path.join(directory, extracted_folder)
  
      if not os.path.exists(extracted_folder):
          logging.info(
              "Extracting weights package to %s", extracted_folder
          )
          os.makedirs(extracted_folder)
          if ".zip" in file_path:
              zip_ref = zipfile.ZipFile(file_path, "r")
              zip_ref.extractall(extracted_folder)
              zip_ref.close()
          elif ".tar.gz" in file_path:  # pragma: no cover
              tar_ref = tarfile.TarFile.open(file_path, "r")
              tar_ref.extractall(extracted_folder)
              tar_ref.close()
      else:
          logging.info(
              "Extraced folder already exists: %s", extracted_folder
          )  # pragma: no cover
  
      return extracted_folder
  
file_path: foolbox/foolbox/zoo/weights_fetcher.py
imports: import requests
  import shutil
  import zipfile
  import tarfile
  import os
  import logging
  from .common import sha256_hash, home_directory_path
label_desc: Use image node_id 4 for calling a global function with example usage: _extract(directory, filename) and returns: extracted_folder