code: def _create_test_saved_model(
      export_in_tf1,
      input_specs,
      preprocessing_fn,
      export_path_suffix=None,
      base_dir=None,
  ):
      if not export_path_suffix:
          export_path = os.path.join(
              tempfile.mkdtemp(dir=base_dir), "export"
          )
      else:
          export_path = os.path.join(
              tempfile.mkdtemp(dir=base_dir), export_path_suffix
          )
      if export_in_tf1:
          with tf.compat.v1.Graph().as_default():
              with tf.compat.v1.Session().as_default() as session:
                  inputs = {}
                  for key in input_specs:
                      tensor_spec = input_specs[key]
                      if isinstance(tensor_spec, tf.TensorSpec):
                          inputs[key] = tf.compat.v1.placeholder(
                              tensor_spec.dtype, shape=tensor_spec.shape
                          )
                      elif isinstance(tensor_spec, tf.SparseTensorSpec):
                          inputs[key] = tf.compat.v1.sparse_placeholder(
                              tensor_spec.dtype, shape=tensor_spec.shape
                          )
                      elif isinstance(tensor_spec, tf.RaggedTensorSpec):
                          inputs[key] = tf.compat.v1.ragged.placeholder(
                              tensor_spec._dtype,
                              tensor_spec._ragged_rank,
                              [],
                          )
                      else:
                          raise ValueError(
                              "TypeSpecs specified should be one of `tf.TensorSpec`, "
                              "`tf.SparseTensorSpec`, `tf.RaggedTensorSpec`"
                          )
                  outputs = preprocessing_fn(inputs)
                  # show that unrelated & unmapped placeholders do not interfere
                  tf.compat.v1.placeholder(tf.int64)
                  saved_transform_io.write_saved_transform_from_session(
                      session, inputs, outputs, export_path
                  )
      else:
          module = tf.Module()
          tf_graph_context = graph_context.TFGraphContext(
              module_to_export=module,
              temp_dir=None,
              evaluated_replacements=None,
          )
          transform_fn = impl_helper.get_traced_transform_fn(
              preprocessing_fn=preprocessing_fn,
              input_signature=input_specs,
              tf_graph_context=tf_graph_context,
              output_keys_to_name_map=None,
          )
  
          saved_transform_io_v2.write_v2_saved_model(
              module, transform_fn, "transform_fn", export_path
          )
      return export_path
  
imports: import os
  import shutil
  import tempfile
  import numpy
  import tensorflow
  from tensorflow_transform import graph_context
  from tensorflow_transform import impl_helper
  from tensorflow_transform import tf_utils
  from tensorflow_transform import test_case
  from tensorflow_transform.py_func.api import apply_pyfunc
  from tensorflow_transform.saved import constants
  from tensorflow_transform.saved import saved_transform_io
  from tensorflow_transform.saved import saved_transform_io_v2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.ops import script_ops
label_desc: Use image node_id 3 for calling a global function with example usage: _create_test_saved_model(export_in_tf1, input_specs, preprocessing_fn, export_path_suffix, base_dir) and returns: export_path