code: def tar_extract(path, mode="r:gz", prefix=None, exists="raise"):
      """
      Extracts tar file into single local directory.
  
      We fail if items in tar file have different <top-directory>.
  
      path:
          The tar file.
      mode:
          As tarfile.open().
      prefix:
          If not None, we fail if tar file's <top-directory> is not <prefix>.
      exists:
          What to do if <top-directory> already exists:
              'raise': raise exception.
              'remove': remove existing file/directory before extracting.
              'return': return without extracting.
  
      Returns the directory name (which will be <prefix> if not None, with '/'
      appended if not already present).
      """
      prefix_actual = tar_check(path, mode, prefix)
      if os.path.exists(prefix_actual):
          if exists == "raise":
              raise Exception(f"Path already exists: {prefix_actual!r}")
          elif exists == "remove":
              remove(prefix_actual)
          elif exists == "return":
              log(
                  f"Not extracting {path} because already exists: {prefix_actual}"
              )
              return prefix_actual
          else:
              assert 0, f"Unrecognised exists={exists!r}"
      assert not os.path.exists(
          prefix_actual
      ), f"Path already exists: {prefix_actual}"
      log(f"Extracting {path}")
      with tarfile.open(path, mode) as t:
          t.extractall()
      return prefix_actual
  
imports: import glob
  import io
  import os
  import textwrap
  import time
  import platform
  import shlex
  import shutil
  import stat
  import subprocess
  import sys
  import tarfile
  import urllib.request
  import zipfile
  import pipcl
  import sys
label_desc: Use image node_id 6 for calling a global function with example usage: tar_extract(path, mode, prefix, exists) and returns: prefix_actual, prefix_actual