<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def intercept(actions: dict={}):
 """ Decorates a function and handles any exceptions that may rise. Args: actions: A dictionary ``<exception type>: <action>``. Available actions\ are :class:`raises` and :class:`returns`. Returns: Any value declared using a :class:`returns` action. Raises: AnyException: if AnyException is declared together with a :class:`raises` action. InterceptorError: if the decorator is called with something different from a :class:`returns` or :class:`raises` action. Interceptors can be declared inline to return a value or raise an exception when the declared exception is risen: 'ok' 'intercepted!' Traceback (most recent call last):
 Exception: intercepted! But they can also be declared and then used later on: 'intercepted!' You can declare also an action that captures the risen exception by passing a callable to the action. This is useful to create a custom error message: 'intercepted inner exception' Or to convert captured exceptions into custom errors: Traceback (most recent call last):
 intercept.CustomError: inner exception """


    for action in actions.values():
        if type(action) is not returns and type(action) is not raises:
            raise InterceptorError('Actions must be declared as `returns` or `raises`')

    def decorated(f):
        def wrapped(*args, **kargs):
            try:
                return f(*args, **kargs)
            except Exception as e:
                if e.__class__ in actions:
                    return actions[e.__class__](e)
                else:
                    raise

        return wrapped

    return decorated