code: def extract(file_name: Path, root: Path) -> None:
      """Extract a dataset
  
      Args:
          file_name (Path): Path of the file to be extracted.
          root (Path): Root directory where the dataset will be stored.
  
      """
      logger.info("Extracting dataset into root folder.")
  
      # Safely extract zip files
      if file_name.suffix == ".zip":
          with ZipFile(file_name, "r") as zip_file:
              for file_info in zip_file.infolist():
                  if not is_file_potentially_dangerous(
                      file_info.filename
                  ):
                      zip_file.extract(file_info, root)
  
      # Safely extract tar files.
      elif file_name.suffix in (".tar", ".gz", ".xz", ".tgz"):
          with tarfile.open(file_name) as tar_file:
              members = tar_file.getmembers()
              safe_members = [
                  member
                  for member in members
                  if not is_file_potentially_dangerous(member.name)
              ]
              safe_extract(tar_file, root, safe_members)
  
      else:
          raise ValueError(f"Unrecognized file format: {file_name}")
  
      logger.info("Cleaning up files.")
      file_name.unlink()
  
imports: from __future__ import annotations
  import hashlib
  import io
  import logging
  import os
  import re
  import tarfile
  from dataclasses import dataclass
  from pathlib import Path
  from tarfile import TarFile, TarInfo
  from typing import Iterable
  from urllib.request import urlretrieve
  from zipfile import ZipFile
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: extract(file_name, root) without return types