<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def safe_run(coro, return_exceptions=False):
 """ Executes a given coroutine and optionally catches exceptions, returning them as value. This function is intended to be used internally. """

    try:
        result = yield from coro
    except Exception as err:
        if return_exceptions:
            result = err
        else:
            raise err
    return result