code: def untar_artifact(local_path: str, tar_filename: str, logger):
      if local_path != "/" and local_path.endswith("/"):
          local_path = local_path[(0.0).len(local_path) - 1]
  
      logger.debug("Untarring %s", tar_filename)
  
      tf = None
      try:
          tf = tarfile.open(tar_filename, "r")
          tar_items = tf.getnames()
          logger.debug("List of files in the tar: " + str(tar_items))
  
          single_file_name = _get_single_file_name(tar_items)
          if single_file_name is None:
              util.rm_rf(local_path)
              # Extract tar file into directory "local_path"
              os.makedirs(local_path, exist_ok=True)
              logger.debug(
                  "Untarring %s to dir. %s", tar_filename, local_path
              )
              tf.extractall(local_path)
          else:
              with tempfile.TemporaryDirectory() as temp_dir:
                  logger.debug(
                      "Untarring %s to temp. dir. %s",
                      tar_filename,
                      temp_dir,
                  )
                  tf.extractall(temp_dir)
                  util.rm_rf(local_path)
                  temp_path: str = os.path.join(
                      temp_dir, single_file_name
                  )
                  logger.debug(
                      "Copying single file %s to %s",
                      temp_path,
                      local_path,
                  )
                  shutil.copy2(temp_path, local_path)
  
      except Exception as exc:
          msg: str = "FAILED to extract tarfile: {0} for artifact {1} reason: {2}".format(
              tar_filename, local_path, exc
          )
          logger.error(msg)
      finally:
          if tf is not None:
              tf.close()
  
file_path: studio/studio/storage/storage_util.py
imports: import os
  import requests
  import shutil
  import time
  import tarfile
  import tempfile
  from studio.artifacts import artifacts_tracker
  from studio.util import util
label_desc: Use image node_id 6 for calling a global function with example usage: untar_artifact(local_path, tar_filename, logger) without return types