def merge_opts(d, opts):
    """merge opts
    Args:
        d (dict): The dict.
        opts (list): The opts to merge. format: [key1, name1, key2, name2,...]
    Returns: d. the input dict `d` with merged opts.

    """
    assert len(opts) % 2 == 0, f'length of opts must be even. Got: {opts}'
    for i in range(0, len(opts), 2):
        full_k, v = opts[i], opts[i + 1]
        keys = full_k.split('.')
        sub_d = d
        for i, k in enumerate(keys):
            if not hasattr(sub_d, k):
                raise ValueError(f'The key {k} not exist in the dict. Full key:{full_k}')
            if i != len(keys) - 1:
                sub_d = sub_d[k]
            else:
                sub_d[k] = v
    return d