code: def test_deserial_errors():
      try:
          MockSerializerForErrors.raises = False
          MockSerializerForErrors.register(CustomList)
          ListSerializer.register(CustomList, name="test_name")
  
          # error of leaf object is raised
          obj = [1, [[3, UnpickleWithError()]]]
          with pytest.raises(ValueError):
              deserialize(*serialize(obj))
  
          # error of leaf object is rewritten in parent object
          obj = CustomList([[1], [[3, UnpickleWithError()]]])
          with pytest.raises(SystemError) as exc_info:
              deserialize(*serialize(obj))
          assert isinstance(exc_info.value.__cause__, ValueError)
  
          MockSerializerForErrors.raises = True
  
          # error of non-leaf object is raised
          obj = [CustomList([[1], [[2]]])]
          with pytest.raises(TypeError):
              deserialize(*serialize(obj))
          deserialize(*serialize(obj, {"serializer": "test_name"}))
  
          # error of non-leaf CustomList is rewritten in parent object
          obj = CustomList([[1], CustomList([[1], [[2]]]), [2]])
          with pytest.raises(SystemError) as exc_info:
              deserialize(*serialize(obj))
          assert isinstance(exc_info.value.__cause__, TypeError)
          deserialize(*serialize(obj, {"serializer": "test_name"}))
      finally:
          MockSerializerForErrors.unregister(CustomList)
          ListSerializer.unregister(CustomList, name="test_name")
          # Above unregister will remove the ListSerializer from deserializers,
          # so we need to register ListSerializer again to make the
          # deserializers correct.
          ListSerializer.register(list)
  
imports: import threading
  from collections import defaultdict, OrderedDict
  from typing import Any, Dict, List, Tuple
  import numpy
  import pandas
  import pytest
  from ...lib.sparse import SparseMatrix
  from ...tests.core import require_cupy, require_cudf
  from ...utils import lazy_import
  from ..None import serialize, serialize_with_spawn, deserialize
  from ..core import Placeholder, ListSerializer
label_desc: Use image node_id 14 for calling a global function with example usage: test_deserial_errors() without return types