What is a decorator in Python? Give an example to time a function.
Implement timed(source), where source is a string containing a function definition decorated with @timed and a call to that function. Execute the source and return a map containing the function's return value and the output prefix produced by the timing decorator. If the function raises an exception, return its exception type and message while still recording the timing output.
The decorator must support positional and keyword arguments, preserve the wrapped function's name, and report timing in the form <name> took ...s.
<function_name> tookdef timed(source):