code: def test_custom_serializer(ray_start_shared_local_modes):
      import threading
  
      class A:
          def __init__(self, x):
              self.x = x
              self.lock = threading.Lock()
  
      def custom_serializer(a):
          return a.x
  
      def custom_deserializer(x):
          return A(x)
  
      ray.util.register_serializer(
          A,
          serializer=custom_serializer,
          deserializer=custom_deserializer,
      )
      ray.get(ray.put(A(1)))
  
      ray.util.deregister_serializer(A)
      with pytest.raises(Exception):
          ray.get(ray.put(A(1)))
  
      # deregister again takes no effects
      ray.util.deregister_serializer(A)
  
imports: import collections
  import io
  import logging
  import re
  import string
  import sys
  import weakref
  from dataclasses import make_dataclass
  import numpy
  import pytest
  from numpy import log
  import ray
  import ray.cluster_utils
label_desc: Use image node_id 12 for calling a global function with example usage: test_custom_serializer(ray_start_shared_local_modes) and returns: a, A