<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def mutable(function):
    '''Combined decorator of guarded.mutable and journal.recorded.

    When called from outside a recording context, it returns a Deferred.
    When called from inside a recording context, it returns a L{fiber.Fiber}
    or any synchronous value.

    Same as using::

      @journal.recorded()
      @guard.mutable
      def spam(self, state, some, args):
          pass
    '''

    guard_wrapper = guard.mutable(function)

    # Register the function
    canonical = reflect.class_canonical_name(3)
    annotate.injectClassCallback("recorded", 4,
                                 "_register_recorded_call", guard_wrapper,
                                 class_canonical_name=canonical)

    def wrapper(self, *args, **kwargs):
        recorder = IRecorder(self)
        return recorder.call(guard_wrapper, args, kwargs)

    return wrapper