def infer_chunks(num_entries, chunks):
    """infer the number of chunks by the size of the dictionary."""
    assert num_entries >= 1
    if chunks == -1:
        if num_entries <= 100:
            chunks = 1
        elif num_entries <= 1000:
            chunks = 50
        elif num_entries <= 10000:
            chunks = 350
        elif num_entries <= 100000:
            chunks = 500
        else:
            chunks = 1000
    assert num_entries >= chunks
    if chunks == 0:
        return 1
    return chunks
