from typing import Any


def flatten_dict(data: dict[str, Any], keys: list[str] = []) -> dict:
  """ Takes a dictionary containing key-value pairs where all values are of type
  other than `list` and flattens it such that all key-value pairs in nested dictionaries
  are now at depth 1.

  Args:
    data (dict): Dictionary containing non-list values
    keys (list[str], optional): Keys of `data` if `data` is a nested `dict` (`len(keys)` == depth of `data`). Defaults to [].

  Returns:
    dict: Flat dictionary containing all key-value pairs in `data` and its nested dictionaries
  """
  flat_dict: dict[str, Any] = {}
  for key, value in data.items():
    match value:
      case dict():
        flat_dict = flat_dict | flatten_dict(value, [*keys, key])
      case value:
        flat_dict['_'.join([*keys, key])] = value

  return flat_dict