code: def run_class_serialization_test(self, instance, custom_objects=None):
      from keras.saving import custom_object_scope
      from keras.saving import deserialize_keras_object
      from keras.saving import serialize_keras_object
  
      # get_config roundtrip
      cls = instance.__class__
      config = instance.get_config()
      config_json = json.dumps(config, sort_keys=True, indent=4)
      ref_dir = dir(instance)[:]
      with custom_object_scope(custom_objects):
          revived_instance = cls.from_config(config)
      revived_config = revived_instance.get_config()
      revived_config_json = json.dumps(
          revived_config, sort_keys=True, indent=4
      )
      self.assertEqual(config_json, revived_config_json)
      self.assertEqual(set(ref_dir), set(dir(revived_instance)))
  
      # serialization roundtrip
      serialized = serialize_keras_object(instance)
      serialized_json = json.dumps(serialized, sort_keys=True, indent=4)
      with custom_object_scope(custom_objects):
          revived_instance = deserialize_keras_object(
              json.loads(serialized_json)
          )
      revived_config = revived_instance.get_config()
      revived_config_json = json.dumps(
          revived_config, sort_keys=True, indent=4
      )
      self.assertEqual(config_json, revived_config_json)
      new_dir = dir(revived_instance)[:]
      for lst in [ref_dir, new_dir]:
          if "__annotations__" in lst:
              lst.remove("__annotations__")
      self.assertEqual(set(ref_dir), set(new_dir))
      return revived_instance
  
imports: import json
  import shutil
  import tempfile
  import unittest
  import numpy
  import tree
  from keras import backend
  from keras import ops
  from keras import utils
  from keras.backend.common import is_float_dtype
  from keras.backend.common import standardize_dtype
  from keras.backend.common.global_state import clear_session
  from keras.backend.common.keras_tensor import KerasTensor
  from keras.models import Model
  from keras.utils import traceback_utils
label_desc: Use image node_id 9 for calling the TestCase obj's underlying member method code with example usage: obj.run_class_serialization_test(instance, custom_objects) and returns: revived_instance