<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def patch(import_path, rvalue=UNDEFINED, side_effect=UNDEFINED, ignore=UNDEFINED, callback=UNDEFINED, ctxt=UNDEFINED, subsequent_rvalue=UNDEFINED):
 """ Patches an attribute of a module referenced on import_path with a decorated version that will use the caliendo cache if rvalue is None. Otherwise it will patch the attribute of the module to return rvalue when called. This class provides a context in which to use the patched module. After the decorated method is called patch_in_place unpatches the patched module with the original method. :param str import_path: The import path of the method to patch. :param mixed rvalue: The return value of the patched method. :param mixed side_effect: The side effect to execute. Either a callable with the same parameters as the target, or an exception. :param caliendo.Ignore ignore: Arguments to ignore. The first element should be a list of positional arguments. The second should be a list of keys for keyword arguments. :param function callback: A pickleable callback to execute when the patched method is called and the cache is hit. (has to have been cached the first time). :param caliendo.hooks.Context ctxt: The context this patch should be executed under. Generally reserved for internal use. The vast majority of use cases should leave this parameter alone. :param mixed subsequent_rvalue: If passed; this will be the return value each time this method is run regardless of what is returned when it is initially cached. Caching for this method will be skipped. This is useful when the method returns something unpickleable but we still need to stub it out. """

    def patch_test(unpatched_test):
        """
        Patches a callable dependency of an unpatched test with a callable corresponding to patch_with.

        :param unpatched_test: The unpatched test for which we're patching dependencies
        :type unpatched_test: instance method of a test suite
        :param patch_with: A callable to patch the callable dependency with. Should match the function signature of the callable we're patching.
        :type patch_with: callable

        :returns: The patched test
        :rtype: instance method
        """
        if ctxt == UNDEFINED:
            context = get_context(unpatched_test)
        else:
            context = ctxt
            context.enter()


        patched_test = get_patched_test(import_path=import_path,
                                        unpatched_test=unpatched_test,
                                        rvalue=rvalue,
                                        side_effect=side_effect,
                                        context=context,
                                        ignore=ignore,
                                        callback=callback,
                                        subsequent_rvalue=subsequent_rvalue)

        patched_test.__context = context
        patched_test.__name__ = context.name

        return patched_test
    return patch_test