<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_patched_request(self, package_requests=None, package_subtractions=None, strict=False, rank=0):
 """Get a 'patched' request. A patched request is a copy of this context's request, but with some changes applied. This can then be used to create a new, 'patched' context. New package requests override original requests based on the type - normal, conflict or weak. So 'foo-2' overrides 'foo-1', '!foo-2' overrides '!foo-1' and '~foo-2' overrides '~foo-1', but a request such as '!foo-2' would not replace 'foo-1' - it would be added instead. Note that requests in `package_requests` can have the form '^foo'. This is another way of supplying package subtractions. Any new requests that don't override original requests are appended, in the order that they appear in `package_requests`. Args: package_requests (list of str or list of `PackageRequest`):
 Overriding requests. package_subtractions (list of str):
 Any original request with a package name in this list is removed, before the new requests are added. strict (bool):
 If True, the current context's resolve is used as the original request list, rather than the request. rank (int):
 If > 1, package versions can only increase in this rank and further - for example, rank=3 means that only version patch numbers are allowed to increase, major and minor versions will not change. This is only applied to packages that have not been explicitly overridden in `package_requests`. If rank <= 1, or `strict` is True, rank is ignored. Returns: List of `PackageRequest` objects that can be used to construct a new `ResolvedContext` object. """

        # assemble source request
        if strict:
            request = []
            for variant in self.resolved_packages:
                req = PackageRequest(variant.qualified_package_name)
                request.append(req)
        else:
            request = self.requested_packages()[:]

        # convert '^foo'-style requests to subtractions
        if package_requests:
            package_subtractions = package_subtractions or []
            indexes = []
            for i, req in enumerate(package_requests):
                name = str(req)
                if name.startswith('^'):
                    package_subtractions.append(name[1:])
                    indexes.append(i)
            for i in reversed(indexes):
                del package_requests[i]

        # apply subtractions
        if package_subtractions:
            request = [x for x in request if x.name not in package_subtractions]

        # apply overrides
        if package_requests:
            request_dict = dict((x.name, (i, x)) for i, x in enumerate(request))
            request_ = []

            for req in package_requests:
                if isinstance(req, basestring):
                    req = PackageRequest(req)

                if req.name in request_dict:
                    i, req_ = request_dict[req.name]
                    if (req_ is not None) and (req_.conflict == req.conflict) \
                            and (req_.weak == req.weak):
                        request[i] = req
                        del request_dict[req.name]
                    else:
                        request_.append(req)
                else:
                    request_.append(req)

            request += request_

        # add rank limiters
        if not strict and rank > 1:
            overrides = set(x.name for x in package_requests if not x.conflict)
            rank_limiters = []
            for variant in self.resolved_packages:
                if variant.name not in overrides:
                    if len(variant.version) >= rank:
                        version = variant.version.trim(rank - 1)
                        version = version.next()
                        req = "~%s<%s" % (variant.name, str(version))
                        rank_limiters.append(req)
            request += rank_limiters

        return request