def create_function_from_response_pdu(resp_pdu, req_pdu=None):
    """ Parse response PDU and return instance of :class:`ModbusFunction` or
    raise error.

    :param resp_pdu: PDU of response.
    :param  req_pdu: Request PDU, some functions require more info than in
        response PDU in order to create instance. Default is None.
    :return: Number or list with response data.
    """
    function_code = pdu_to_function_code_or_raise_error(resp_pdu)
    function = function_code_to_function_map[function_code]

    if req_pdu is not None and \
        'req_pdu' in inspect.getargspec(function.create_from_response_pdu).args:  # NOQA

        return function.create_from_response_pdu(resp_pdu, req_pdu)

    return function.create_from_response_pdu(resp_pdu)