def flatten_dict(input_dict: dict, separator: str = '_', prefix: str = ''):
    """ Flatten a (possibly nested) dictionary

    Args:
        input_dict: the input dictionary to flatten
        separator: string used to merge nested keys. It defaults to "_"
        prefix: used in the recursive calls. Do not set manually
    """
    return {prefix + separator + k if prefix else k: v
            for kk, vv in input_dict.items()
            for k, v in flatten_dict(vv, separator, kk).items()
            } if isinstance(input_dict, dict) else {prefix: input_dict}