The work of re-implement checkpoint saving(c1e6672f3141015371968b9fb371a5b40abee837) ruined custom saving and restoring op！
@k-w-w @liangyaning33  I need a solution to upgrade the code. Hi, unfortunately the _SingleDeviceSaver is not part of the public API and can change at any time. 

If  you're trying to add custom save/restore steps we do have a `register_checkpoint_saver` mechanism for doing this (also private but more likely to be surfaced as a public API symbol): 
https://github.com/tensorflow/tensorflow/blob/f104fe5d323dddd20cfa41e12ac2efbc08baf598/tensorflow/python/saved_model/registration/registration.py#L198-L321

There is an example here:
https://github.com/tensorflow/tensorflow/blob/f104fe5d323dddd20cfa41e12ac2efbc08baf598/tensorflow/python/saved_model/registration/registration_saving_test.py#L45-L116

For your case, since (at a brief glance) the Variable is being saved to another file, your `save_fn` and `restore_fn` would look something like:

```
def save_fn(trackables, file_prefix):
  """Save stack and part objects to a checkpoint shard."""
  for v in trackables:
    # Write v to file
  return []

def restore_stacks_and_parts(trackables, merged_prefix):
  for v in trackables:
    # Read and assign v from file
```


 > Hi, unfortunately the _SingleDeviceSaver is not part of the public API and can change at any time.
> 
> If you're trying to add custom save/restore steps we do have a `register_checkpoint_saver` mechanism for doing this (also private but more likely to be surfaced as a public API symbol):
> 
> https://github.com/tensorflow/tensorflow/blob/f104fe5d323dddd20cfa41e12ac2efbc08baf598/tensorflow/python/saved_model/registration/registration.py#L198-L321
> 
> There is an example here:
> 
> https://github.com/tensorflow/tensorflow/blob/f104fe5d323dddd20cfa41e12ac2efbc08baf598/tensorflow/python/saved_model/registration/registration_saving_test.py#L45-L116
> 
> For your case, since (at a brief glance) the Variable is being saved to another file, your `save_fn` and `restore_fn` would look something like:
> 
> ```
> def save_fn(trackables, file_prefix):
>   """Save stack and part objects to a checkpoint shard."""
>   for v in trackables:
>     # Write v to file
>   return []
> 
> def restore_stacks_and_parts(trackables, merged_prefix):
>   for v in trackables:
>     # Read and assign v from file
> ```

Thank you very much for your reply. And I have another question, is this mechanism compatible with apis such as tf.keras.models.save_model? This is compatible with SavedModel but must be used with `register_serializable`.  When loading, the same objects and checkpoint saver must be registered otherwise you may see errors. > This is compatible with SavedModel but must be used with `register_serializable`. When loading, the same objects and checkpoint saver must be registered otherwise you may see errors.

Not only in python API restoring, but also the save_fn would be serialized to op graph saved in the saved_model.pb? I mean when I restore my model using C++ API (model serving), does it would run the custom restoring op graph just like old patching way.
### Issue Type

Feature Request

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

Yes

### Source

source

### Tensorflow Version

tf 2.12

### Custom Code

Yes

### Python version

Python 3.8/3.9

### Current Behaviour?

For many TensorFlow developers, it is common to customize project-specific variables. To make a particular Variable compatible with the TensorFlow API, it is common to set some private member within its SaveableObject. Also  we need to override the _SingleDeviceSaver saving and restore function for adding custom ops chain into graph. 


For examples: https://github.com/tensorflow/recommenders-addons/blob/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/tf_save_restore_patch.py


Now commit c1e6672f3141015371968b9fb371a5b40abee837 have ruined them all.

### Standalone code to reproduce the issue

https://github.com/tensorflow/recommenders-addons

run CI failed in TF 2.12.