code: def test_graph2vec():
      """
      Test the Graph2Vec embedding.
      """
      graphs = [
          nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)
      ]
      new_graphs = [
          nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(130)
      ]
  
      model = Graph2Vec()
  
      model.fit(graphs)
      embedding = model.get_embedding()
  
      new_embedding = model.infer(new_graphs)
  
      assert embedding.shape[0] == len(graphs)
      assert embedding.shape[1] == model.dimensions
  
      assert new_embedding.shape[0] == len(new_graphs)
      assert new_embedding.shape[1] == model.dimensions
  
      graphs = [
          nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)
      ]
  
      model = Graph2Vec(erase_base_features=True)
  
      model.fit(graphs)
      embedding = model.get_embedding()
  
      assert embedding.shape[0] == len(graphs)
      assert embedding.shape[1] == model.dimensions
  
      graphs = []
  
      for _ in range(50):
          graph = nx.newman_watts_strogatz_graph(50, 5, 0.3)
          nx.set_node_attributes(
              graph, {j: str(j) for j in range(50)}, "feature"
          )
          graphs.append(graph)
  
      new_graphs = []
  
      for _ in range(50):
          graph = nx.newman_watts_strogatz_graph(75, 10, 0.2)
          nx.set_node_attributes(
              graph, {j: str(j) for j in range(75)}, "feature"
          )
          new_graphs.append(graph)
  
      model = Graph2Vec(use_node_attribute="feature")
  
      model.fit(graphs)
      embedding = model.get_embedding()
  
      assert embedding.shape[0] == len(graphs)
      assert embedding.shape[1] == model.dimensions
      assert type(embedding) == np.ndarray
  
      new_embedding = model.infer(new_graphs)
  
      assert new_embedding.shape[0] == len(new_graphs)
      assert new_embedding.shape[1] == model.dimensions
      assert type(new_embedding) == np.ndarray
  
      with pytest.raises(ValueError):
          model = Graph2Vec(
              use_node_attribute="missing_feature",
          )
  
          model.fit(new_graphs)
  
file_path: karateclub/test/graph_embedding_test.py
imports: import numpy
  import networkx
  import pytest
  from karateclub.graph_embedding import Graph2Vec, FGSD, GL2Vec, SF, IGE, LDP
  from karateclub.graph_embedding import NetLSD, GeoScattering, FeatherGraph
label_desc: Use image node_id 3 for calling a global function with example usage: test_graph2vec() without return types