code: def test_nodemapper_with_labels():
      n_feat = 4
      n_batch = 2
  
      # test graph
      G2 = example_graph_2(n_feat)
      nodes = list(G2.nodes())
      labels = [n * 2 for n in nodes]
  
      gen = GraphSAGENodeGenerator(
          G2, batch_size=n_batch, num_samples=[2, 2]
      ).flow(nodes, labels)
      assert len(gen) == 3
  
      for ii in range(3):
          nf, nl = gen[ii]
  
          # Check sizes - note batch sizes are (2,2,1) for each iteration
          assert len(nf) == 3
          assert nf[0].shape[1:] == (1, n_feat)
          assert nf[1].shape[1:] == (2, n_feat)
          assert nf[2].shape[1:] == (2 * 2, n_feat)
  
          # Check labels
          assert all(
              int(a) == int(2 * b) for a, b in zip(nl, nf[0][:, 0, 0])
          )
  
      # Check beyond the graph lengh
      with pytest.raises(IndexError):
          nf, nl = gen[len(gen)]
  
imports: from stellargraph.core.graph import *
  from stellargraph.mapper import *
  import networkx
  import numpy
  import random
  import pytest
  import pandas
  import scipy.sparse
  from ..test_utils.graphs import example_graph, example_graph_random, example_hin_1, create_graph_features, repeated_features, weighted_tree
  from ..None import test_utils
label_desc: Use image node_id 9 for calling a global function with example usage: test_nodemapper_with_labels() without return types