class_docstr: Base class with helper functions for backward compatibility tests.
code: def run_serialized(
      self,
      data: CompatTestData,
      polymorphic_shapes: Sequence[str] | None = None,
  ):
      args_specs = export.symbolic_args_specs(
          data.inputs, polymorphic_shapes
      )
  
      def ndarray_to_aval(a: np.ndarray) -> core.ShapedArray:
          return core.ShapedArray(a.shape, a.dtype)
  
      in_avals_tree = tree_util.tree_map(ndarray_to_aval, args_specs)
      # TODO: we ought to ensure that out_avals are polymorphic if need be. We
      # could either save the in/out_avals (but we need to first implement that
      # support in export), or we can just re-use them from the current
      # exported.
      out_avals_tree = tree_util.tree_map(
          ndarray_to_aval, data.expected_outputs
      )
      # in_tree must be for (args, kwargs)
      in_avals, in_tree = tree_util.tree_flatten((in_avals_tree, {}))
      out_avals, out_tree = tree_util.tree_flatten(out_avals_tree)
  
      def _get_vjp(_):
          assert False  # We do not have and do not need VJP
  
      exported = export.Exported(
          fun_name="run_serialized",
          in_tree=in_tree,
          in_avals=tuple(in_avals),
          out_tree=out_tree,
          out_avals=tuple(out_avals),
          in_shardings=(None,) * len(in_avals),
          out_shardings=(None,) * len(out_avals),
          lowering_platforms=(data.platform,),
          ordered_effects=(),
          unordered_effects=(),
          disabled_safety_checks=(),
          mlir_module_serialized=data.mlir_module_serialized,
          mlir_module_serialization_version=data.xla_call_module_version,
          nr_devices=data.nr_devices,
          module_kept_var_idx=tuple(range(len(in_avals))),
          uses_shape_polymorphism=any(
              not core.is_constant_shape(a.shape) for a in in_avals
          ),
          _get_vjp=_get_vjp,
      )
  
      # We use pjit in case there are shardings in the exported module.
      return pjit.pjit(export.call_exported(exported))(*data.inputs)
  
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 8 for calling the CompatTestBase obj's underlying member method code with example usage: obj.run_serialized(data, polymorphic_shapes) and returns: pjit, core