from typing import OrderedDict


def merge_before_after(info_before, info_after):
    """
    Merge two dicts into one. This is used when updating network weights.
    We merge the update info before update and after update into one dict.

    Args:
        info_before: the dictionary containing the information before updating
        info_after: the dictionary containing the information after updating

    Return:
        info: the merged dictionary
    """
    info = OrderedDict()
    for k in info_before:
        info[k + '_before'] = info_before[k]
        info[k + '_after'] = info_after[k]
    return info