from typing import Dict
from typing import OrderedDict


def auto_map_args(d: Dict, slots: OrderedDict):
    """
    Auto map a dict of data to a pre-defined slots

    Args:
        d: a dict of data
        slots: pre-defined slots

    Returns:
        - a tuple of data, where the order of data corresponds to the key orders in slots
    """
    kwargs = OrderedDict()
    for key, val in slots.items():
        kwargs[key] = val
    for key, val in d.items():
        kwargs[key] = val
    args = tuple([v for _, v in kwargs.items()])
    while len(args) > 0:
        if args[-1] is None:
            args = args[:-1]
        else:
            break
    return args