<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run_option_hooks(parser, disable_missing=True):
 """ Executes registered plugins using option hooks for the provided ``SettingParser`` instance. `parser` ``SettingParser`` instance. `disable_missing` Set to ``True`` to disable any plugins using option hooks whose defined option hooks are not available in the data returned from the parser. * Raises ``InvalidTaskConfig`` if task config parsing failed. """


    plugins = []
    state = {}  # state information

    def _raise_error(msg, block):
        """ Raises ``InvalidTaskConfig`` exception with given message.
            """
        if block:
            msg += u' (block: "{0}")'.format(block)

        raise errors.InvalidTaskConfig(parser.filename, reason=msg)

    def _run_hooks(options, block):
        """ Runs option hooks for the block and options provided.
            """

        for option, value_list in options:
            key = '{0}_{1}'.format(block, option) if block else option
            item = _option_hooks.get(key)

            if item:
                plugin_obj, props = item

                # enforce some properties
                if not key in state:
                    state[key] = 0
                state[key] += 1

                # currently only supports 'allow_duplicates'
                if not props.get('allow_duplicates', True) and state[key] > 1:
                    msg = u'Duplicate option "{0}"'.format(option)
                    _raise_error(msg, block)

                try:
                    plugin_obj.parse_option(option, block, *value_list)
                    plugins.append(plugin_obj)

                except TypeError:  # invalid value length
                    msg = u'Value mismatch for option "{0}"'.format(option)
                    _raise_error(msg, block)

                except ValueError as exc:
                    msg = unicode(exc)
                    if not msg:
                        msg = (u'Invalid value provided for option "{0}"'
                               .format(option))

                    _raise_error(msg, block)

            else:  # invalid key found
                msg = u'Invalid option "{0}" found'.format(option)
                _raise_error(msg, block)

    # run hooks for non-block options
    _run_hooks(parser.options, None)

    # run hooks for blocks
    for block, option_list in parser.blocks:
        _run_hooks(option_list, block)

    # disable any plugins using option hooks that didn't match parser data
    if disable_missing:
        reg_plgs = get_registered(option_hooks=True)

        for plugin in [p for p in reg_plgs if p not in plugins]:
            disable_plugin_instance(plugin)