KerasLegacyOptimizer fails type check in keras.optimizers.get (ValueError: Could not interpret optimizer identifier)
@ben-arnao 
TensorFlow Addons (TFA) has ended development and introduction of new features.
TFA has entered a minimal maintenance and release mode until a planned end of life in May 2024.
Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP). 

For more information see: https://github.com/tensorflow/addons/issues/2807 

Please refer to this official document for further assistance:
https://github.com/ianstenbit/keras-cv/blob/master/.github/CONTRIBUTING.md#contributing-custom-ops


Thank you ! @ben-arnao -
There are two issues in the code provided -
1. `tensorflow.python.keras` is deprecated.  Please use `from tensorflow import keras` or `import keras`.  See Readme.md here - https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/keras

2. You can sublcass Legacy Optimizer directly from `keras.optimizers.legacy.Optimizer` and don't see a need to use TF Addons here. I mean just sounds like at this point I have to re-write the optimizer then. Maybe it should be noted somewhere a bit more explicitly that something like KerasLegacyOptimizer doesn't work with TF2. There are many examples online of writing optimizers the old way so it is a bit confusing. 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/60332">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/60332">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

2.12

### Custom Code

Yes

### OS Platform and Distribution

Windows 10

### Mobile device

_No response_

### Python version

3.10

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

RTX 2070

### Current Behaviour?

I am trying to create a customer optimizer using KerasLegacyOptimizer as a lot of the examples in https://github.com/tensorflow/addons/tree/master/tensorflow_addons/optimizers are using. Looks like we are failing at this line https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/optimizers.py#L118

Any ideas?

### Standalone code to reproduce the issue

```shell
from tensorflow.python.keras.models import Sequential
from tensorflow_addons.optimizers import KerasLegacyOptimizer


class CustomerOptimizer(KerasLegacyOptimizer):
    def __init__(
        self,
        name: str = "CustomerOptimize",
        **kwargs,
    ):
        super().__init__(name, **kwargs)


model = Sequential()
optimizer = CustomerOptimizer()
model.compile(optimizer=optimizer)
```


### Relevant log output

```shell
Traceback (most recent call last):
  File "C:\Users\Ben\PycharmProjects\AutoTab\test2.py", line 17, in <module>
    model.compile(optimizer=optimizer)
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\keras\engine\training.py", line 568, in compile
    self.optimizer = self._get_optimizer(optimizer)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\keras\engine\training.py", line 606, in _get_optimizer
    return nest.map_structure(_get_single_optimizer, optimizer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\util\nest.py", line 917, in map_structure
    structure[0], [func(*x) for x in entries],
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\util\nest.py", line 917, in <listcomp>
    structure[0], [func(*x) for x in entries],
                   ^^^^^^^^
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\keras\engine\training.py", line 597, in _get_single_optimizer
    opt = optimizers.get(opt)
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\PycharmProjects\AutoTab\venv\Lib\site-packages\tensorflow\python\keras\optimizers.py", line 131, in get
    raise ValueError(
ValueError: Could not interpret optimizer identifier: <__main__.CustomerOptimizer object at 0x0000024363063350>
```
</details>