code: def is_within_directory(directory: Path, target: Path):
      """Checks if a target path is located within a given directory.
  
      Args:
          directory (Path): path of the parent directory
          target (Path): path of the target
      Returns:
          (bool): True if the target is within the directory, False otherwise
      """
      abs_directory = directory.resolve()
      abs_target = target.resolve()
  
      # TODO: replace with pathlib is_relative_to after switching to Python 3.10
      prefix = os.path.commonprefix([abs_directory, abs_target])
      return prefix == str(abs_directory)
  
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 6 for calling a global function with example usage: is_within_directory(directory, target) and returns: unknown