def METHOD_NAME():
    # leave here to avoid import issues
    from moto.core import utils as moto_utils
    # make sure we properly handle/propagate "not implemented" errors
    @patch(moto_utils.convert_to_flask_response.__call__)
    def convert_to_flask_response_call(fn, *args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except NotImplementedError as e:
            action = request.headers.get("X-Amz-Target")
            action = action or f"{request.method} {urlparse(request.url).path}"
            if action == "POST /":
                # try to extract action from exception string
                match = re.match(r"The ([a-zA-Z0-9_-]+) action has not been implemented", str(e))
                if match:
                    action = snake_to_camel_case(match.group(1))
            service = extract_service_name_from_auth_header(request.headers)
            exception_message: str | None = e.args[0] if e.args else None
            msg = exception_message or get_coverage_link_for_service(service, action)
            response = requests_error_response(request.headers, msg, code=501)
            if config.MOCK_UNIMPLEMENTED:
                is_json = is_json_request(request.headers)
                headers = {HEADER_CONTENT_TYPE: APPLICATION_JSON if is_json else APPLICATION_XML}
                content = "{}" if is_json else "<Response />"  # TODO: return proper mocked response
                response = requests_response(content, headers=headers)
                LOG.info(f"{msg}. Returning mocked response due to MOCK_UNIMPLEMENTED=1")
            else:
                LOG.info(msg)
            # TODO: publish analytics event ...
            return requests_to_flask_response(response)
    if config.USE_SINGLE_REGION:
        return
    # make sure that we inherit THREAD_LOCAL request contexts to spawned sub-threads
    @patch(FuncThread.__init__)
    def thread_init(fn, self, *args, **kwargs):
        self._req_context = get_request_context()
        return fn(self, *args, **kwargs)
    @patch(FuncThread.run)
    def thread_run(fn, self, *args, **kwargs):
        try:
            if self._req_context:
                THREAD_LOCAL.request_context = self._req_context
        except AttributeError:
            # sometimes there is a race condition where the previous patch has not been applied yet
            pass
        return fn(self, *args, **kwargs)