Repository: tensorflow
Issue: Crash when calling TFSMLayer object during TF_lite conversion
Labels: stat:awaiting tensorflower,comp:lite,TFLiteConverter,2.17

### 1. System information

- Linux Ubuntu 24.04
- TF 2.17.0 (pip) and Keras 3.5.0

### 2. Code

A TF model is first exported using Keras 3.5.0:

```model.export(model_name)```

Then when the following method is called below, the conversion crashes in TF 2.17.0 (log below). It works fine with TF 2.16.2.

```
def makeQuantizedTFmodel(A, dP):
    import tensorflow as tf    
    A2 = tf.cast(A, tf.float32)
    A = tf.data.Dataset.from_tensor_slices((A2)).batch(1)
    
    def representative_dataset_gen():
        for input_value in A.take(100):
            yield[input_value]
  
            import keras
            model = keras.layers.TFSMLayer(model_name), call_endpoint='serve')    
            converter = tf.lite.TFLiteConverter.from_keras_model(model)    

            converter.optimizations = [tf.lite.Optimize.DEFAULT]
            converter.representative_dataset = representative_dataset_gen
            converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
            converter.inference_input_type = tf.uint8
            converter.inference_output_type = tf.uint8
            tflite_quant_model = converter.convert()

            with open(model_name+'.tflite', 'wb') as o:
                   o.write(tflite_quant_model)
```

The error with TF 2.17.0:

```
Traceback (most recent call last):
  File "/home/nicola/test/DML/DataML.py", line 1008, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/nicola/test/DML/DataML.py", line 160, in main
    train(sys.argv[2], None, None)
  File "/home/nicola/test/DML/DataML.py", line 398, in train
    makeQuantizedTFmodel(A, dP)
  File "/home/nicola/test/DML/libDataML.py", line 231, in makeQuantizedTFmodel
    tflite_quant_model = converter.convert()
                         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/lite.py", line 1231, in wrapper
    return self._convert_and_export_metrics(convert_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/lite.py", line 1183, in _convert_and_export_metrics
    result = convert_func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/lite.py", line 1749, in convert
    self._freeze_keras_model()
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/convert_phase.py", line 215, in wrapper
    raise error from None  # Re-throws the exception.
    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/convert_phase.py", line 205, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/lite.py", line 1690, in _freeze_keras_model
    input_signature = _model_input_signature(
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/tensorflow/lite/python/tflite_keras_util.py", line 119, in model_input_signature
    input_specs = model._get_save_spec(  # pylint: disable=protected-access
                  ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TFSMLayer' object has no attribute '_get_save_spec'. Did you mean: '_set_save_spec'?
```