code: def extract_tarfile_to(tarfileobj, target_path, archive_path):
      """Extract TarFile contents under archive_path/ to target_path/"""
  
      target_path = os.path.abspath(target_path)
  
      def get_members():
          for member in tarfileobj.getmembers():
              if archive_path:
                  norm_path = os.path.normpath(member.name)
                  if norm_path.startswith(archive_path + os.path.sep):
                      member.name = norm_path[len(archive_path) + 1 :]
                  else:
                      continue
  
              dst_path = os.path.abspath(
                  os.path.join(target_path, member.name)
              )
              if (
                  os.path.commonpath([target_path, dst_path])
                  != target_path
              ):
                  # Path not under target_path, probably contains ../
                  continue
  
              yield member
  
      tarfileobj.extractall(target_path, members=get_members())
  
imports: import glob
  import hashlib
  import os
  import platform
  import sysconfig
  import sys
  import shutil
  import tarfile
  import textwrap
  import zipfile
  from tempfile import mkstemp, gettempdir
  from urllib.request import urlopen, Request
  from urllib.error import HTTPError
label_desc: Use image node_id 9 for calling a global function with example usage: extract_tarfile_to(tarfileobj, target_path, archive_path) without return types