code: def test_serialization_before_init(shutdown_only):
      """This test checks if serializers registered before initializing Ray
      works after initialization."""
      # make sure ray is shutdown
      ray.shutdown()
      assert ray._private.worker.global_worker.current_job_id.is_nil()
  
      import threading
  
      class A:
          def __init__(self, x):
              self.x = x
              self.lock = threading.Lock()  # could not be serialized!
  
      def custom_serializer(a):
          return a.x
  
      def custom_deserializer(b):
          return A(b)
  
      # Register serializer and deserializer for class A:
      ray.util.register_serializer(
          A,
          serializer=custom_serializer,
          deserializer=custom_deserializer,
      )
  
      # Initialize Ray later.
      ray.init()
      ray.get(ray.put(A(1)))
  
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 15 for calling a global function with example usage: test_serialization_before_init(shutdown_only) and returns: a, A