keras/src/legacy/saving/serialization.py/_shared_object_saving_scope
def _shared_object_saving_scope():
    """Get the current shared object saving scope in a threadsafe manner."""
    return getattr(SHARED_OBJECT_SAVING, "scope", None)