code: def extract_archive(archive_path, dest):
    
    # Make the dest folder if it does not exist
    if not os.path.isdir(dest):
      os.makedirs(dest)
  
    try:
      tmpfolder = None
  
      if (not tf.gfile.Exists(archive_path)) or tf.gfile.IsDirectory(archive_path):
        raise ValueError('archive path %s is not a file' % archive_path)
  
      if archive_path.startswith('gs://'):
        # Copy the file to a local temp folder
        tmpfolder = tempfile.mkdtemp()
        cmd_args = ['gsutil', 'cp', archive_path, tmpfolder]
        _shell_process.run_and_monitor(cmd_args, os.getpid())
        archive_path = os.path.join(tmpfolder, os.path.name(archive_path))
  
      if archive_path.lower().endswith('.tar.gz'):
        flags = '-xzf'
      elif archive_path.lower().endswith('.tar'):
        flags = '-xf'
      else:
        raise ValueError('Only tar.gz or tar.Z files are supported.')
  
      cmd_args = ['tar', flags, archive_path, '-C', dest]
      _shell_process.run_and_monitor(cmd_args, os.getpid())
    finally:
      if tmpfolder:
        shutil.rmtree(tmpfolder)
docs: Extract a local or GCS archive file to a folder.
  
    Args:
      archive_path: local or gcs path to a *.tar.gz or *.tar file
      dest: local folder the archive will be extracted to