<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scoped(self, func):
 """ Decorator to switch scopes. """

        @wraps(func)
        def wrapper(*args, **kwargs):
            scope = kwargs.get("scope", self.__factory__.default_scope)
            with self.scoped_to(scope):
                return func(*args, **kwargs)
        return wrapper