# Buggy code
def init_model(
    lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1
):
    """
    Create a new model from raw data, like word frequencies, Brown clusters
    and word vectors.
    """
    if not freqs_loc.exists():
        prints(freqs_loc, title="Can't find words frequencies file", exits=1)
    clusters_loc = ensure_path(clusters_loc)
    vectors_loc = ensure_path(vectors_loc)

    probs, oov_prob = read_freqs(freqs_loc)
    vectors_data, vector_keys = read_vectors(vectors_loc) if vectors_loc else None, None
    clusters = read_clusters(clusters_loc) if clusters_loc else {}

    nlp = create_model(
        lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors
    )

    if not output_dir.exists():
        output_dir.mkdir()
    nlp.to_disk(output_dir)
    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 init_model(
    lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1
):
    """
    Create a new model from raw data, like word frequencies, Brown clusters
    and word vectors.
    """
    if not freqs_loc.exists():
        prints(freqs_loc, title="Can't find words frequencies file", exits=1)
    clusters_loc = ensure_path(clusters_loc)
    vectors_loc = ensure_path(vectors_loc)

    probs, oov_prob = read_freqs(freqs_loc)
    vectors_data, vector_keys = (
        read_vectors(vectors_loc) if vectors_loc else (None, None)
    )
    clusters = read_clusters(clusters_loc) if clusters_loc else {}

    nlp = create_model(
        lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors
    )

    if not output_dir.exists():
        output_dir.mkdir()
    nlp.to_disk(output_dir)
    return nlp