class_docstr: Base class with helper functions for backward compatibility tests.
docstr: Serializes the test function.
  
  Args:
    func: the function to serialize
    polymorphic_shapes: the polymorphic_shapes to use for serialization
    allow_unstable_custom_call_targets: whether to allow additional
      custom call targets besides those known as stable.
  
  Returns: a tuple with the (a) serialization, (b) the module contents as
    a string (for debugging), (c) the module serialization version,
    (d) the number of devices for which the module was serialized.
docstr_tok: ["Serializes","the","test","function",".","Args",":","func",":","the","function","to","serialize","polymorphic_shapes",":","the","polymorphic_shapes","to","use","for","serialization","allow_unstable_custom_call_targets",":","whether","to","allow","additional","custom","call","targets","besides","those","known","as","stable",".","Returns",":","a","tuple","with","the","(","a",")","serialization",",","(","b",")","the","module","contents","as","a","string","(","for","debugging",")",",","(","c",")","the","module","serialization","version",",","(","d",")","the","number","of","devices","for","which","the","module","was","serialized","."]
code: def serialize(
      self,
      func: Callable,
      data: CompatTestData,
      *,
      polymorphic_shapes: Sequence[str] | None = None,
      allow_unstable_custom_call_targets: Sequence[str] = (),
  ) -> tuple[bytes, str, int, int]:
      """Serializes the test function.
  
      Args:
        func: the function to serialize
        polymorphic_shapes: the polymorphic_shapes to use for serialization
        allow_unstable_custom_call_targets: whether to allow additional
          custom call targets besides those known as stable.
  
      Returns: a tuple with the (a) serialization, (b) the module contents as
        a string (for debugging), (c) the module serialization version,
        (d) the number of devices for which the module was serialized.
      """
      # Use the native exporter, to make sure we get the proper serialization.
      args_specs = export.symbolic_args_specs(
          data.inputs, polymorphic_shapes
      )
      exported = export.export(
          jax.jit(func),
          lowering_platforms=(self.default_jax_backend(),),
          disabled_checks=tuple(
              export.DisabledSafetyCheck.custom_call(target)
              for target in allow_unstable_custom_call_targets
          ),
      )(*args_specs)
  
      module_str = str(exported.mlir_module())
      serialized = exported.mlir_module_serialized
      module_version = exported.mlir_module_serialization_version
      nr_devices = exported.nr_devices
      return serialized, module_str, module_version, nr_devices
  
imports: from __future__ import annotations
  from collections.abc import Iterable, Sequence
  import dataclasses
  import datetime
  import os
  import re
  import sys
  from typing import Any, Callable
  from absl import logging
  import numpy
  from numpy import array, float32
  import jax
  from jax import tree_util
  from jax.experimental import export
  from jax.experimental import pjit
  from jax._src import core
  from jax._src import test_util
  from jax._src import xla_bridge
label_desc: Use image node_id 7 for calling the CompatTestBase obj's underlying member method code with example usage: obj.serialize(func, data) and returns: serialized,  module_str,  module_version,  nr_devices