code: def test_word2vec(self):
      print("-" * 20, "test_word2vec", "-" * 20)
  
      def get_word2vec():
          vocabulary_size = 800
          batch_size = 10
          embedding_size = 60
          num_sampled = 25
          inputs = tl.layers.Input([batch_size], dtype=tf.int32)
          labels = tl.layers.Input([batch_size, 1], dtype=tf.int32)
  
          emb_net = tl.layers.Word2vecEmbedding(
              vocabulary_size=vocabulary_size,
              embedding_size=embedding_size,
              num_sampled=num_sampled,
              activate_nce_loss=True,  # nce loss is activated
              nce_loss_args={},
              E_init=tl.initializers.random_uniform(
                  minval=-1.0, maxval=1.0
              ),
              nce_W_init=tl.initializers.truncated_normal(
                  stddev=float(1.0 / np.sqrt(embedding_size))
              ),
              nce_b_init=tl.initializers.constant(value=0.0),
              name="word2vec_layer",
          )
          emb, nce = emb_net([inputs, labels])
  
          model = tl.models.Model(
              inputs=[inputs, labels], outputs=[emb, nce]
          )
          return model
  
      net = get_word2vec()
  
      for k, v in enumerate(net._node_by_depth):
          print(k, [x.name for x in v], [x.in_tensors_idxes for x in v])
  
      x = tf.ones(shape=(10,), dtype=tf.int32)
      y = tf.ones(shape=(10, 1), dtype=tf.int32)
      out = net([x, y], is_train=True)
  
      self.assertEqual(len(out), 2)
  
file_path: TensorLayer/tests/layers/test_layernode.py
imports: import os
  import unittest
  import numpy
  import tensorflow
  from tensorflow.python.ops.rnn_cell import LSTMCell
  import tensorlayer
  from tensorlayer.layers import *
  from tensorlayer.models import Model
  from tests.utils import CustomTestCase
label_desc: Use image node_id 5 for calling the LayerNode_Test obj's underlying member method code with example usage: obj.test_word2vec() and returns: model