code: def test_corrupt_graphsage_generator(is_directed):
      G = example_graph_random(n_nodes=20, is_directed=is_directed)
  
      if is_directed:
          generator = DirectedGraphSAGENodeGenerator(
              G, batch_size=5, in_samples=[2, 3], out_samples=[4, 1]
          )
      else:
          generator = GraphSAGENodeGenerator(
              G, batch_size=5, num_samples=[2, 3]
          )
  
      base_gen = generator.flow(G.nodes())
      gen = CorruptedGenerator(generator).flow(G.nodes())
  
      x, targets = gen[0]
      clean_feats, _ = base_gen[0]
  
      shuffled_feats = x[: (len(x) // 2)]
      features = x[(len(x) // 2) :]
  
      assert len(clean_feats) == len(features)
      assert len(x) == 2 * len(clean_feats)
      assert len(features) == len(shuffled_feats)
      assert all(
          f.shape == s.shape for f, s in zip(features, shuffled_feats)
      )
  
      # check shuffled_feats do seem to be shuffled
      assert not all(
          np.array_equal(_sorted_feats([shuf]), _sorted_feats(feat))
          for shuf, feat in zip(shuffled_feats, features)
      )
  
      # check that all feature vecs in shuffled_feats correspond to a feature vec in features
      np.testing.assert_array_equal(
          _sorted_feats(shuffled_feats), _sorted_feats(features)
      )
  
file_path: stellargraph/tests/mapper/test_corrupted.py
imports: import pytest
  import numpy
  from stellargraph.mapper import *
  from ..test_utils.graphs import example_graph_random
label_desc: Use image node_id 10 for calling a global function with example usage: test_corrupt_graphsage_generator(is_directed) without return types