<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _dispatch(self, operation, request, path_args):
 """ Wrapped dispatch method, prepare request and generate a HTTP Response. """

        # Determine the request and response types. Ensure API supports the requested types
        request_type = resolve_content_type(self.request_type_resolvers, request)
        request_type = self.remap_codecs.get(request_type, request_type)
        try:
            request.request_codec = self.registered_codecs[request_type]
        except KeyError:
            return HttpResponse.from_status(HTTPStatus.UNPROCESSABLE_ENTITY)

        response_type = resolve_content_type(self.response_type_resolvers, request)
        response_type = self.remap_codecs.get(response_type, response_type)
        try:
            request.response_codec = self.registered_codecs[response_type]
        except KeyError:
            return HttpResponse.from_status(HTTPStatus.NOT_ACCEPTABLE)

        # Check if method is in our allowed method list
        if request.method not in operation.methods:
            return HttpResponse.from_status(
                HTTPStatus.METHOD_NOT_ALLOWED,
                {'Allow': ','.join(m.value for m in operation.methods)}
            )

        # Response types
        resource, status, headers = self.dispatch_operation(operation, request, path_args)

        if isinstance(status, HTTPStatus):
            status = status.value

        # Return a HttpResponse and just send it!
        if isinstance(resource, HttpResponse):
            return resource

        # Encode the response
        return create_response(request, resource, status, headers)