code: def loads(frames, deserialize=True, deserializers=None):
      """Transform bytestream back into Python value"""
  
      try:
  
          def _decode_default(obj):
              offset = obj.get("__Serialized__", 0)
              if offset > 0:
                  sub_header = msgpack.loads(
                      frames[offset],
                      object_hook=msgpack_decode_default,
                      use_list=False,
                      **msgpack_opts,
                  )
                  offset += 1
                  sub_frames = frames[
                      offset : offset + sub_header["num-sub-frames"]
                  ]
                  if deserialize:
                      if "compression" in sub_header:
                          sub_frames = decompress(
                              sub_header, sub_frames
                          )
                      return merge_and_deserialize(
                          sub_header,
                          sub_frames,
                          deserializers=deserializers,
                      )
                  else:
                      return Serialized(sub_header, sub_frames)
  
              offset = obj.get("__Pickled__", 0)
              if offset > 0:
                  sub_header = msgpack.loads(frames[offset])
                  offset += 1
                  sub_frames = frames[
                      offset : offset + sub_header["num-sub-frames"]
                  ]
                  if "compression" in sub_header:
                      sub_frames = decompress(sub_header, sub_frames)
                  return pickle.loads(
                      sub_header["pickled-obj"], buffers=sub_frames
                  )
              return msgpack_decode_default(obj)
  
          return msgpack.loads(
              frames[0],
              object_hook=_decode_default,
              use_list=False,
              **msgpack_opts,
          )
  
      except Exception:
          logger.critical("Failed to deserialize", exc_info=True)
          raise
  
file_path: distributed/distributed/protocol/core.py
imports: from __future__ import annotations
  import logging
  import msgpack
  from distributed.protocol import pickle
  from distributed.protocol.compression import decompress, maybe_compress
  from distributed.protocol.serialize import Pickled, Serialize, Serialized, ToPickle, _is_msgpack_serializable, merge_and_deserialize, msgpack_decode_default, msgpack_encode_default, serialize_and_split
  from distributed.protocol.utils import msgpack_opts
  from distributed.utils import ensure_memoryview
label_desc: Use image node_id 2 for calling a global function with example usage: loads(frames, deserialize, deserializers) and returns: msgpack, msgpack_decode_default, pickle, merge_and_deserialize, Serialized