def flatten(data: dict):
    """
    Convert Dictionary into Non-nested Dictionary
    Example:
        input(dict)
            {
                "menu": [
                    {"name" : ["cake"], "count" : ["2"]},
                    {"name" : ["juice"], "count" : ["1"]},
                ]
            }
        output(list)
            [
                ("menu.name", "cake"),
                ("menu.count", "2"),
                ("menu.name", "juice"),
                ("menu.count", "1"),
            ]
    """
    flatten_data = list()

    def _flatten(value, key=""):
        if type(value) is dict:
            for child_key, child_value in value.items():
                _flatten(child_value, f"{key}.{child_key}" if key else child_key)
        elif type(value) is list:
            for value_item in value:
                _flatten(value_item, key)
        else:
            flatten_data.append((key, value))

    _flatten(data)
    return flatten_data

    Convert Dictionary into Non-nested Dictionary
    Example:
        input(dict)
            {
                "menu": [
                    {"name" : ["cake"], "count" : ["2"]},
                    {"name" : ["juice"], "count" : ["1"]},
                ]
            }
        output(list)
            [
                ("menu.name", "cake"),
                ("menu.count", "2"),
                ("menu.name", "juice"),
                ("menu.count", "1"),
            ]
    
vlmeval/dataset/utils/ccocr_evaluator/kie_evaluator.py