code: def _save_model_with_custom_attributes(
      export_dir, temp_dir, save_from_keras=False
  ):
      """Writes a Hub-style SavedModel with a custom attributes."""
      # Calling the module parses an integer.
      f = lambda a: tf.strings.to_number(a, tf.int64)
      if save_from_keras:
          inp = tf_keras_v2.layers.Input(shape=(1,), dtype=tf.string)
          outp = tf_keras_v2.layers.Lambda(f)(inp)
          model = tf_keras_v2.Model(inp, outp)
      else:
          model = tf.train.Checkpoint()
          model.__call__ = tf.function(
              input_signature=[
                  tf.TensorSpec(shape=(None, 1), dtype=tf.string)
              ]
          )(f)
  
      # Running on the `sample_input` file yields the `sample_output` value.
      asset_source_file_name = os.path.join(temp_dir, "number.txt")
      tf.io.gfile.makedirs(temp_dir)
      with tf.io.gfile.GFile(asset_source_file_name, "w") as f:
          f.write("12345\n")
      model.sample_input = tf.saved_model.Asset(asset_source_file_name)
      model.sample_output = tf.Variable([[12345]], dtype=tf.int64)
  
      # Save model and invalidate the original asset file name.
      tf.saved_model.save(model, export_dir)
      tf.io.gfile.remove(asset_source_file_name)
      return export_dir
  
imports: import json
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_hub
label_desc: Use image node_id 9 for calling a global function with example usage: _save_model_with_custom_attributes(export_dir, temp_dir, save_from_keras) and returns: export_dir