code: def compress_to_tar_gz_in_memory(upload_entries) -> bytes:
      f = io.BytesIO(b"")
  
      with tarfile.TarFile.open(
          fileobj=f, mode="w|gz", dereference=True
      ) as archive:
          for entry in upload_entries:
              archive.add(
                  name=entry.source,
                  arcname=entry.target_path,
                  recursive=True,
              )
  
      f.seek(0)
      data = f.read()
      return data
  
file_path: neptune-client/src/neptune/common/storage/datastream.py
imports: import dataclasses
  import io
  import math
  import os
  import tarfile
  from typing import Any, Generator, Optional
  from neptune.common.backends.api_model import MultipartConfig
  from neptune.common.exceptions import InternalClientError, UploadedFileChanged
label_desc: Use image node_id 1 for calling a global function with example usage: compress_to_tar_gz_in_memory(upload_entries) and returns: data