Unable to load TensorFlow saved model (AttributeError: '_UserObject' object has no attribute 'add_slot')
@RabJon Could you please try to use the latest TF 2.13 as you are using an older version. 
In order to expedite the trouble-shooting process, please provide a complete code snippet to reproduce the issue reported here. Thank you! I faced similar but slightly opposite issue once with `tf.saved_model.load` API but worked in ` tf.keras.models.load_model` API. 

https://www.kaggle.com/competitions/google-universal-image-embedding/discussion/336534#1882377 @sushreebarsa unfortunately there is no GPU support after TF 2.10 for Windows Native. Therefore, I tried TF 2.10 instead of the newest version, but the result was the same as for the versions 2.6 and 2.7.

However, I could reproduce the exception on Google Colab with v2.13. Here is the URL for the notebook: [Model_Load_Problem.ipynb](https://colab.research.google.com/drive/1YyyU6kyn947JCuTHOrjRiDGQb2XBOueu?usp=sharing)  Thank you @innat  for the comment. Unfortunately, in my case both approaches to loading models do not work. @RabJon Generally this error is caused because the model you are trying to load was saved using a newer version of TensorFlow than the one you are currently using. To fix this, you will need to upgrade your TensorFlow installation.

To upgrade TensorFlow, run the following command:
```
!pip install tensorflow --upgrade
```
Once you have upgraded TensorFlow, you can reload the model by running the following code:

``` 
model = tf.keras.models.load_model(path)
```
Please let us know if it helps?
Thank you! @sushreebarsa  I tried to run the same code with TF v2.7 and TF v2.10 on Windows Native and I always got the same exception. Since v2.10, which was released in September 2022, is the latest version of TF for Windows Native it would have been impossible for me to save the models with a newer version than that. Furthermore, many of my models are older than the release date of v2.10 so they were created with a lower version for sure.

I am fine for now, because I managed to load the models through a loophole in my implementation that I actually never thought to be useful: I did not only save the entire model in "saved_model" format, but I also saved the model weights alone as h5 files. Given that I didn't change the model architecture I could recreate and compile the models and then just load the corresponding weights from the h5 files. So, personally I don't need a solution anymore. However, I think that this is still a general issue that needs to be solved. @RabJon  Thank you for your response here!

Yes, you can always use the .h5 extension in case you are using two different versions for training and loading the models.  In the HDF5 format with a .h5 extension you can save weights manually. 
Could you please move this issue to closed status if it has been resolved from your end? 
Starting with TensorFlow 2.11, you will need to install [TensorFlow in WSL2](https://tensorflow.org/install/pip#windows-wsl2), or install tensorflow or tensorflow-cpu and, optionally, try the [TensorFlow-DirectML-Plugin](https://github.com/microsoft/tensorflow-directml-plugin#tensorflow-directml-plugin-)
Thank you! Yes, I will close this issue, because it is solved from my site. However, I want to point out again that this was only possible because I decided to save both the entire TensorFlow model (in "saved_model" format) and the weights of the trained model (as .h5 file). So, it was due to my (lucky) design decision that I could solve this issue! Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61972">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61972">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

2.7.0

### Custom code

Yes

### OS platform and distribution

Windows 10 Enterprise LTSC

### Mobile device

_No response_

### Python version

3.9.12

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

11.2/8

### GPU model and memory

Nvidia Geforce RTX 3090 24 GB

### Current behavior?

I have several trained TensorFlow models stored on my device in saved_model format. All the models have the same architecture and serve the same purpose, but they were created at different points in time. While I have no problems to load the newest models (created from 5th September 2022 onward) with the command `tensorflow.keras.models.load_model(filepath)`, older models that were created before this date raise the following exception when this method is called:

> AttributeError: '_UserObject' object has no attribute 'add_slot'

The same exception is also raised when trying to load these models with: `tensorflow.saved_model.load(filepath)`, which was one of the suggestions I found to solve the issue. Another possible solution that I took from the related issue #52091 was to use another TF version, I tried it with the older v2.6 and the newest Windows native version v.2.10, but the result was the same.

### Standalone code to reproduce the issue

[EDIT] I could reproduce the exception on Google Colab using the newest TF version. Please find the notebook here: [Model_Load_Problem.ipynb](https://colab.research.google.com/drive/1YyyU6kyn947JCuTHOrjRiDGQb2XBOueu?usp=sharing)


### Relevant log output

```shell
2023-09-25 11:36:20.048929: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-09-25 11:36:21.096591: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 18788 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:1a:00.0, compute capability: 8.6
Traceback (most recent call last):
  File "C:\Users\icon\Desktop\Testing_Models\iCoNet\source\model.py", line 699, in load_trained_model
    model = tf.keras.models.load_model(model_path)
  File "C:\Users\icon\.conda\envs\iConNet\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\icon\.conda\envs\iConNet\lib\site-packages\tensorflow\python\saved_model\load.py", line 466, in _load_nodes
    slot_variable = optimizer_object.add_slot(
AttributeError: '_UserObject' object has no attribute 'add_slot'
```
