code: def test_nodemapper_isolated_nodes():
      n_feat = 4
      n_batch = 2
  
      # test graph (a lot of edges between the 5 non-isolated nodes, to ensure they're a single
      # connected component)
      G = example_graph_random(
          feature_size=n_feat, n_nodes=6, n_isolates=1, n_edges=1000
      )
  
      # Check connectedness
      Gnx = G.to_networkx()
      ccs = list(nx.connected_components(Gnx))
      assert len(ccs) == 2
  
      n_isolates = [5]
      assert nx.degree(Gnx, n_isolates[0]) == 0
  
      # Check both isolated and non-isolated nodes have same sampled feature shape
      for head_nodes in [[1], [2], n_isolates]:
          mapper = GraphSAGENodeGenerator(
              G, batch_size=n_batch, num_samples=[2, 2]
          ).flow(head_nodes)
          nf, nl = mapper[0]
          assert nf[0].shape == (1, 1, n_feat)
          assert nf[1].shape == (1, 2, n_feat)
          assert nf[2].shape == (1, 4, n_feat)
  
      # One isolate and one non-isolate
      mapper = GraphSAGENodeGenerator(
          G, batch_size=n_batch, num_samples=[2, 2]
      ).flow([1, 5])
      nf, nl = mapper[0]
      assert nf[0].shape == (2, 1, n_feat)
      assert nf[1].shape == (2, 2, n_feat)
      assert nf[2].shape == (2, 4, n_feat)
  
      # Isolated nodes have the "dummy node" as neighbours
      # Currently, the dummy node has zeros for features – this could change
      assert pytest.approx(nf[1][1]) == 0
      assert pytest.approx(nf[2][2:]) == 0
  
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 11 for calling a global function with example usage: test_nodemapper_isolated_nodes() without return types