code: def parse_config(
      option_manager: OptionManager,
      cfg: configparser.RawConfigParser,
      cfg_dir: str,
  ) -> dict[str, Any]:
      """Parse and normalize the typed configuration options."""
      if "flake8" not in cfg:
          return {}
  
      config_dict = {}
  
      for option_name in cfg["flake8"]:
          option = option_manager.config_options_dict.get(option_name)
          if option is None:
              LOG.debug(
                  'Option "%s" is not registered. Ignoring.',
                  option_name,
              )
              continue
  
          # Use the appropriate method to parse the config value
          value: Any
          if option.type is int or option.action == "count":
              value = cfg.getint("flake8", option_name)
          elif option.action in {"store_true", "store_false"}:
              value = cfg.getboolean("flake8", option_name)
          else:
              value = cfg.get("flake8", option_name)
  
          LOG.debug(
              'Option "%s" returned value: %r', option_name, value
          )
  
          final_value = option.normalize(value, cfg_dir)
  
          if option_name in {"ignore", "extend-ignore"}:
              for error_code in final_value:
                  if not VALID_CODE_PREFIX.match(error_code):
                      raise ValueError(
                          f"Error code {error_code!r} "
                          f"supplied to {option_name!r} option "
                          f"does not match {VALID_CODE_PREFIX.pattern!r}"
                      )
  
          assert option.config_name is not None
          config_dict[option.config_name] = final_value
  
      return config_dict
  
file_path: flake8/src/flake8/options/config.py
imports: from __future__ import annotations
  import configparser
  import logging
  import os.path
  from typing import Any
  from flake8 import exceptions
  from flake8.defaults import VALID_CODE_PREFIX
  from flake8.options.manager import OptionManager
label_desc: Use image node_id 4 for calling a global function with example usage: parse_config(option_manager, cfg, cfg_dir) and returns: config_dict, dict