code: def unpack_archive_with_buffer(buffer, format="gztar"):
      """Unpack archive with archive buffer
      After the call is finished, the archive file and directory will be deleted.
  
      Implementation process:
          1. create 'tempfile' in '~/tmp/' and directory
          2. 'buffer' write to 'tempfile'
          3. unpack archive file('tempfile')
          4. user does something with file_path('tempfile/')
          5. remove 'tempfile' and 'tempfile directory'
  
      :param buffer: bytes
      :param format: archive format: one of "zip", "tar", "gztar", "bztar", or "xztar"
      :return: unpack archive directory path
  
      Usage::
  
          >>> # The following code is to print all the file names in 'test_unpack.tar.gz'
          >>> with open('test_unpack.tar.gz') as fp:
          ...     buffer = fp.read()
          ...
          >>> with unpack_archive_with_buffer(buffer) as temp_dir:
          ...     for f_n in os.listdir(temp_dir):
          ...         print(f_n)
          ...
  
      """
      temp_dir = os.path.expanduser("~/tmp")
      if not os.path.exists(temp_dir):
          os.makedirs(temp_dir)
      with tempfile.NamedTemporaryFile(
          "wb", delete=False, dir=temp_dir
      ) as fp:
          fp.write(buffer)
          file_path = fp.name
  
      try:
          tar_file = file_path + ".tar.gz"
          os.rename(file_path, tar_file)
          # Create dir
          os.makedirs(file_path)
          shutil.unpack_archive(
              tar_file, format=format, extract_dir=file_path
          )
  
          # Return temp dir
          yield file_path
  
      except Exception as e:
          log.error(str(e))
      finally:
          # Remove temp tar file
          if os.path.exists(tar_file):
              os.unlink(tar_file)
  
          # Remove temp model dir
          if os.path.exists(file_path):
              shutil.rmtree(file_path)
  
file_path: qlib/qlib/utils/file.py
imports: import os
  import shutil
  import tempfile
  import contextlib
  from typing import Optional, Text, IO, Union
  from pathlib import Path
  from qlib.log import get_module_logger
label_desc: Use image node_id 3 for calling a global function with example usage: unpack_archive_with_buffer(buffer, format) without return types