'Build the model graph.'

def build_graph(self):

    opts = self._options
    (words, counts, words_per_epoch, current_epoch, total_words_processed, examples, labels) = word2vec.skipgram_word2vec(filename=opts.train_data, batch_size=opts.batch_size, window_size=opts.window_size, min_count=opts.min_count, subsample=opts.subsample)
    (opts.vocab_words, opts.vocab_counts, opts.words_per_epoch) = self._session.run([words, counts, words_per_epoch])
    opts.vocab_size = len(opts.vocab_words)
    print('Data    file:    ', opts.train_data)
    print('Vocab    size:    ', (opts.vocab_size - 1), '    +    UNK')
    print('Words    per    epoch:    ', opts.words_per_epoch)
    self._id2word = opts.vocab_words
    for (i, w) in enumerate(self._id2word):
        self._word2id[w] = i
    w_in = tf.Variable(tf.random_uniform([opts.vocab_size, opts.emb_dim], ((-0.5) / opts.emb_dim), (0.5 / opts.emb_dim)), name='w_in')
    w_out = tf.Variable(tf.zeros([opts.vocab_size, opts.emb_dim]), name='w_out')
    global_step = tf.Variable(0, name='global_step')
    words_to_train = float((opts.words_per_epoch * opts.epochs_to_train))
    lr = (opts.learning_rate * tf.maximum(0.0001, (1.0 - (tf.cast(total_words_processed, tf.float32) / words_to_train))))
    inc = global_step.assign_add(1)
    with tf.control_dependencies([inc]):
        train = word2vec.neg_train_word2vec(w_in, w_out, examples, labels, lr, vocab_count=opts.vocab_counts.tolist(), num_negative_samples=opts.num_samples)
    self._w_in = w_in
    self._examples = examples
    self._labels = labels
    self._lr = lr
    self._train = train
    self.global_step = global_step
    self._epoch = current_epoch
    self._words = total_words_processed
