keras/src/backend/common/stateless_scope.py/StatelessScope/__exit__
class StatelessScope:    def __exit__(self, *args, **kwargs):
        global_state.set_global_attribute(
            "stateless_scope", self.original_scope
        )
        if self.original_scope is None and self.initialize_variables:
            # We're back in eager scope;
            # if any variables were created within the stateless
            # scope, we initialize them here.
            from keras.src.backend.common.variables import (
                initialize_all_variables,
            )

            initialize_all_variables()