code: def pep574_dumps(obj: t.Any) -> tuple[bytes, bytes, list[int]]:
      buffers: list[pickle.PickleBuffer] = []
      main_bytes: bytes = pickle.dumps(
          obj, protocol=5, buffer_callback=buffers.append
      )
  
      if not buffers:
          return main_bytes, b"", []
  
      buffer_bytess: list[bytes] = [
          buff.raw().tobytes() for buff in buffers
      ]
  
      for buff in buffers:
          buff.release()
  
      indices: list[int] = [0]
      for buff_bytes in buffer_bytess:
          start = indices[-1]
          end = start + len(buff_bytes)
          indices.append(end)
  
      concat_buffer_bytes: bytes = b"".join(buffer_bytess)
      return main_bytes, concat_buffer_bytes, indices
  
file_path: BentoML/src/bentoml/_internal/utils/pickle.py
imports: from __future__ import annotations
  import io
  import pickle
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: pep574_dumps(obj) and returns: main_bytes,  concat_buffer_bytes,  indices, main_bytes,  bytes,  list