def read_dictionary(path, multivals=False, func_key=lambda x: x, func_val=lambda x: x):
    """
    Parameters
    ----------
    path: str
    multivals: bool, default False
    func_key: function: str -> Any
    func_val: function: str -> Any

    Returns
    -------
    dict[Any, Any] or dict[Any, list[Any]]
    """
    d = {}
    for line in open(path):
        line = line.strip().split()
        if multivals:
            if len(line) == 2:
                key, val = line
                vals = [val]
            else:
                key = line[0]
                vals = line[1:]
            d[func_key(key)] = [func_val(val) for val in vals]
        else:
            if len(line) == 2:
                key, val = line
            else:
                key = line[0]
                val = " ".join(line[1:])
            d[func_key(key)] = func_val(val)
    return d