code: def extract_archive(
      archive_path: str, archive_type: Optional[ArchiveType] = None
  ) -> List[str]:
      """Extracts files from archive (into the same directory), returns a list of extracted files.
  
      Args:
          archive_path - The full path to the archive.
  
      Returns A list of the files extracted.
      """
      if archive_type is None:
          archive_type = infer_archive_type(archive_path)
      if archive_type == ArchiveType.UNKNOWN:
          logger.error(
              f"Could not infer type of archive {archive_path}.  May be an unsupported archive type."
              "Specify archive_type in the dataset config if this file has an unknown file extension."
          )
          return []
      archive_directory = os.path.dirname(archive_path)
      directory_contents_before = os.listdir(archive_directory)
      with upload_output_directory(archive_directory) as (tmpdir, _):
          if archive_type == ArchiveType.ZIP:
              with ZipFile(archive_path) as zfile:
                  zfile.extractall(tmpdir)
          elif archive_type == ArchiveType.GZIP:
              gzip_content_file = ".".join(
                  archive_path.split(".")[:-1]
              )  # Path minus the .gz extension
              with gzip.open(archive_path) as gzfile:
                  with open(
                      os.path.join(tmpdir, gzip_content_file), "wb"
                  ) as output:
                      shutil.copyfileobj(gzfile, output)
          elif archive_type in {
              ArchiveType.TAR,
              ArchiveType.TAR_ZIP,
              ArchiveType.TAR_BZ2,
              ArchiveType.TAR_GZ,
          }:
              with tarfile.open(archive_path) as tar_file:
  
                  def is_within_directory(directory, target):
                      abs_directory = os.path.abspath(directory)
                      abs_target = os.path.abspath(target)
  
                      prefix = os.path.commonprefix(
                          [abs_directory, abs_target]
                      )
  
                      return prefix == abs_directory
  
                  def safe_extract(
                      tar,
                      path=".",
                      members=None,
                      *,
                      numeric_owner=False,
                  ):
                      for member in tar.getmembers():
                          member_path = os.path.join(path, member.name)
                          if not is_within_directory(path, member_path):
                              raise Exception(
                                  "Attempted Path Traversal in Tar File"
                              )
  
                      tar.extractall(
                          path, members, numeric_owner=numeric_owner
                      )
  
                  safe_extract(tar_file, path=tmpdir)
          else:
              logger.error(f"Unsupported archive: {archive_path}")
      directory_contents_after = set(os.listdir(archive_directory))
      return directory_contents_after.difference(
          directory_contents_before
      )
  
file_path: ludwig/ludwig/datasets/archives.py
imports: import gzip
  import logging
  import os
  import shutil
  import tarfile
  from enum import Enum
  from typing import List, Optional
  from zipfile import ZipFile
  from ludwig.utils.fs_utils import upload_output_directory
label_desc: Use image node_id 4 for calling a global function with example usage: extract_archive(archive_path, archive_type) and returns: directory_contents_after, list, unknown