code: def test_different_compression_families():
      """Test serialization of a collection of items that use different compression
  
      This scenario happens for instance when serializing collections of
      cupy and numpy arrays.
      """
  
      class MyObjWithCompression:
          pass
  
      class MyObjWithNoCompression:
          pass
  
      def my_dumps_compression(obj, context=None):
          if not isinstance(obj, MyObjWithCompression):
              raise NotImplementedError()
          header = {"compression": [True]}
          return header, [bytes(2**20)]
  
      def my_dumps_no_compression(obj, context=None):
          if not isinstance(obj, MyObjWithNoCompression):
              raise NotImplementedError()
  
          header = {"compression": [False]}
          return header, [bytes(2**20)]
  
      def my_loads(header, frames):
          return pickle.loads(frames[0])
  
      register_serialization_family(
          "with-compression", my_dumps_compression, my_loads
      )
      register_serialization_family(
          "no-compression", my_dumps_no_compression, my_loads
      )
  
      header, _ = serialize(
          [MyObjWithCompression(), MyObjWithNoCompression()],
          serializers=("with-compression", "no-compression"),
          on_error="raise",
          iterate_collection=True,
      )
      assert header["compression"] == [True, False]
  
imports: from __future__ import annotations
  import copy
  import pickle
  from array import array
  import msgpack
  import pytest
  from tlz import identity
  import dask
  from distributed import Nanny, wait
  from distributed.comm.utils import from_frames, to_frames
  from distributed.protocol import Serialize, Serialized, dask_serialize, deserialize, deserialize_bytes, dumps, loads, nested_deserialize, register_serialization, register_serialization_family, serialize, serialize_bytelist, serialize_bytes, to_serialize
  from distributed.protocol.serialize import _is_msgpack_serializable, check_dask_serializable
  from distributed.utils import ensure_memoryview, nbytes
  from distributed.utils_test import NO_AMM, gen_test, inc
  from dask import delayed
  from distributed.utils_test import gen_cluster
label_desc: Use image node_id 26 for calling a global function with example usage: test_different_compression_families() and returns: header,  list, header,  list, pickle