def safe_extract(tar_file: TarFile, root: Path, members: list[TarInfo]) -> None:
    """Safely extract members from a tar archive.

    Args:
        tar_file: TarFile object to extract from
        root: Root directory for extraction
        members: List of safe members to extract
    """
    for member in members:
        # check if the file already exists
        if not (root / member.name).exists():
            if sys.version_info[:3] >= (3, 11, 4):
                # filter argument only works with python>=3.11.4
                tar_file.extract(member, root, filter="data")
            else:
                tar_file.extract(member, root)
Safely extract members from a tar archive.

    Args:
        tar_file: TarFile object to extract from
        root: Root directory for extraction
        members: List of safe members to extract
    
src/anomalib/data/utils/download.py