class_docstr: Implementation of the Node2Vec algorithm of A. Grover and J. Leskovec with Keras layers.
  see: https://snap.stanford.edu/node2vec/
  
  The model minimally requires specification of the embedding size and a generator object.
  
  .. seealso::
  
     Examples using Node2Vec:
  
     - `node classification <https://stellargraph.readthedocs.io/en/stable/demos/node-classification/keras-node2vec-node-classification.html>`__
     - `unsupervised representation learning <https://stellargraph.readthedocs.io/en/stable/demos/embeddings/keras-node2vec-embeddings.html>`__
     - `comparison of link prediction algorithms <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/homogeneous-comparison-link-prediction.html>`__
     - using Gensim Word2Vec, not this class: `node classification <https://stellargraph.readthedocs.io/en/stable/demos/node-classification/node2vec-node-classification.html>`__, `node classification with edge weights <https://stellargraph.readthedocs.io/en/stable/demos/node-classification/node2vec-weighted-node-classification.html>`__, `link prediction <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/node2vec-link-prediction.html>`__, `unsupervised representation learning <https://stellargraph.readthedocs.io/en/stable/demos/embeddings/node2vec-embeddings.html>`__.
  
     Appropriate data generators: :class:`.Node2VecNodeGenerator`, :class:`.Node2VecLinkGenerator`.
  
     Related functionality: :class:`.BiasedRandomWalk` does the underlying random walks.
  
  Args:
      emb_size (int): The dimension of node embeddings.
      generator (Sequence): A NodeSequence or LinkSequence.
      node_num(int, optional): The number of nodes in the given graph.
      multiplicity (int, optional): The number of nodes to process at a time. This is 1 for a node inference
        and 2 for link inference (currently no others are supported).
code: def __init__(
      self, emb_size, generator=None, node_num=None, multiplicity=None
  ):
      # Get the node_num from the generator if it is given
      self.generator = generator
      if generator is not None:
          self._get_sizes_from_generator(generator)
      else:
          self.input_node_num = _require_without_generator(
              node_num, "node_num"
          )
          self.multiplicity = _require_without_generator(
              multiplicity, "multiplicity"
          )
  
      # Model parameters
      self.emb_size = emb_size
  
      # Initialise the target embedding layer: input-to-hidden
      target_embedding_initializer = keras.initializers.RandomUniform(
          minval=-1.0, maxval=1.0
      )
      self.target_embedding = Embedding(
          self.input_node_num,
          self.emb_size,
          input_length=1,
          name="target_embedding",
          embeddings_initializer=target_embedding_initializer,
      )
  
      # Initialise the context embedding layer: hidden-to-output
      context_embedding_initializer = (
          keras.initializers.TruncatedNormal(
              stddev=1.0 / math.sqrt(self.emb_size * 1.0)
          )
      )
      self.context_embedding = Embedding(
          self.input_node_num,
          self.emb_size,
          input_length=1,
          name="context_embedding",
          embeddings_initializer=context_embedding_initializer,
      )
  
file_path: stellargraph/stellargraph/layer/node2vec.py
imports: from tensorflow.keras import Input
  from tensorflow.keras.layers import Reshape, Embedding
  import math
  from tensorflow import keras
  import warnings
  from .misc import deprecated_model_function
  from ..mapper import Node2VecLinkGenerator, Node2VecNodeGenerator
label_desc: Use image node_id 1 to create a new Node2Vec object  with example: obj = Node2Vec(emb_size, generator, node_num, multiplicity)