# Buggy code
def create_model(
    lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors
):
    print("Creating model...")
    lang_class = get_lang_class(lang)
    nlp = lang_class()
    for lexeme in nlp.vocab:
        lexeme.rank = 0

    lex_added = 0
    for i, (word, prob) in enumerate(
        tqdm(sorted(probs.items(), key=lambda item: item[1], reverse=True))
    ):
        lexeme = nlp.vocab[word]
        lexeme.rank = i
        lexeme.prob = prob
        lexeme.is_oov = False
        # Decode as a little-endian string, so that we can do & 15 to get
        # the first 4 bits. See _parse_features.pyx
        if word in clusters:
            lexeme.cluster = int(clusters[word][::-1], 2)
        else:
            lexeme.cluster = 0
        lex_added += 1
    nlp.vocab.cfg.update({"oov_prob": oov_prob})

    if vectors_data:
        nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
    if prune_vectors >= 1:
        nlp.vocab.prune_vectors(prune_vectors)
    vec_added = len(nlp.vocab.vectors)

    prints(
        "{} entries, {} vectors".format(lex_added, vec_added),
        title="Sucessfully compiled vocab",
    )
    return nlp


# Traceback (AttributeError)
Counting frequencies...
923130it [00:02, 309685.80it/s]
Reading vectors...
108821it [00:11, 9870.09it/s]
Reading clusters...
1047705it [00:47, 22187.37it/s]
Creating model...
100%|██████████████████████████████| 36888/36888 [00:01<00:00, 21654.38it/s]
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/user/Documents/spacy-dev-resources/.venv/lib/python2.7/site-packages/spacy/__main__.py", line 31, in <module>
plac.call(commands[command], sys.argv[1:])
File "/home/user/Documents/spacy-dev-resources/.venv/local/lib/python2.7/site-packages/plac_core.py", line 328, in call
cmd, result = parser.consume(arglist)
File "/home/user/Documents/spacy-dev-resources/.venv/local/lib/python2.7/site-packages/plac_core.py", line 207, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File "/home/user/Documents/spacy-dev-resources/.venv/local/lib/python2.7/site-packages/spacy/cli/init_model.py", line 42, in init_model
nlp = create_model(lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors)
File "/home/user/Documents/spacy-dev-resources/.venv/local/lib/python2.7/site-packages/spacy/cli/init_model.py", line 73, in create_model
nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
File "vectors.pyx", line 56, in spacy.vectors.Vectors.__init__
AttributeError: 'tuple' object has no attribute 'shape'

# Fixed code
def create_model(
    lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors
):
    print("Creating model...")
    lang_class = get_lang_class(lang)
    nlp = lang_class()
    for lexeme in nlp.vocab:
        lexeme.rank = 0

    lex_added = 0
    for i, (word, prob) in enumerate(
        tqdm(sorted(probs.items(), key=lambda item: item[1], reverse=True))
    ):
        lexeme = nlp.vocab[word]
        lexeme.rank = i
        lexeme.prob = prob
        lexeme.is_oov = False
        # Decode as a little-endian string, so that we can do & 15 to get
        # the first 4 bits. See _parse_features.pyx
        if word in clusters:
            lexeme.cluster = int(clusters[word][::-1], 2)
        else:
            lexeme.cluster = 0
        lex_added += 1
    nlp.vocab.cfg.update({"oov_prob": oov_prob})

    if len(vectors_data):
        nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
    if prune_vectors >= 1:
        nlp.vocab.prune_vectors(prune_vectors)
    vec_added = len(nlp.vocab.vectors)

    prints(
        "{} entries, {} vectors".format(lex_added, vec_added),
        title="Sucessfully compiled vocab",
    )
    return nlp