code: def serialize_keras_object(obj):
      if hasattr(tf.keras.utils, "legacy"):
          return tf.keras.utils.legacy.serialize_keras_object(obj)
      else:
          return tf.keras.utils.serialize_keras_object(obj)
  
imports: import inspect
  import math
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: serialize_keras_object(obj) and returns: tf, tf