from typing import Iterable


def build_vocab(items, add_unk=True, add_pad=True):
    """ build vocabularies from a item list
    Args:
        items: list of items
        add_unk: bool. Whether to add unk 
    
    >>> build_vocab(["a","b","b"], add_unk=False, add_pad=True)
    {'a': 1, 'b': 2, '<PAD>': 1e+20}
    """
    assert isinstance(items, Iterable), "input 'items' is not iterable"
    dic = {}
    for item in items:
        dic[item] = dic.get(item, 0) + 1
    if add_pad:
        dic['<PAD>'] = 1e20
    if add_unk:
        dic['<UNK>'] = 1e10
    return dic