code: def parse_pyproject_toml(path_config: str) -> Dict[str, Any]:
      """Parse a pyproject toml file, pulling out relevant parts for Black.
  
      If parsing fails, will raise a tomllib.TOMLDecodeError.
      """
      with open(path_config, "rb") as f:
          pyproject_toml = tomllib.load(f)
      config: Dict[str, Any] = pyproject_toml.get("tool", {}).get(
          "black", {}
      )
      config = {
          k.replace("--", "").replace("-", "_"): v
          for k, v in config.items()
      }
  
      if "target_version" not in config:
          inferred_target_version = infer_target_version(pyproject_toml)
          if inferred_target_version is not None:
              config["target_version"] = [
                  v.name.lower() for v in inferred_target_version
              ]
  
      return config
  
imports: import io
  import os
  import sys
  from functools import lru_cache
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Optional, Pattern, Sequence, Tuple, Union
  from mypy_extensions import mypyc_attr
  from packaging.specifiers import InvalidSpecifier, Specifier, SpecifierSet
  from packaging.version import InvalidVersion, Version
  from pathspec import PathSpec
  from pathspec.patterns.gitwildmatch import GitWildMatchPatternError
  from black.handle_ipynb_magics import jupyter_dependencies_are_installed
  from black.mode import TargetVersion
  from black.output import err
  from black.report import Report
label_desc: Use image node_id 3 for calling a global function with example usage: parse_pyproject_toml(path_config) and returns: config