code: def test_intersection():
      G = nx.Graph()
      H = nx.Graph()
      G.add_nodes_from([1, 2, 3, 4])
      G.add_edge(1, 2)
      G.add_edge(2, 3)
      H.add_nodes_from([1, 2, 3, 4])
      H.add_edge(2, 3)
      H.add_edge(3, 4)
      I = nx.intersection(G, H)
      assert set(I.nodes()) == {1, 2, 3, 4}
      assert sorted(I.edges()) == [(2, 3)]
  
      ##################
      # Tests for @nx._dispatchable mechanism with multiple graph arguments
      # nx.intersection is called as if it were a re-implementation
      # from another package.
      ###################
      G2 = dispatch_interface.convert(G)
      H2 = dispatch_interface.convert(H)
      I2 = nx.intersection(G2, H2)
      assert set(I2.nodes()) == {1, 2, 3, 4}
      assert sorted(I2.edges()) == [(2, 3)]
      # Only test if not performing auto convert testing of backend implementations
      if not nx.utils.backends._dispatchable._automatic_backends:
          with pytest.raises(TypeError):
              nx.intersection(G2, H)
          with pytest.raises(TypeError):
              nx.intersection(G, H2)
  
imports: import os
  import pytest
  import networkx
  from networkx.classes.tests import dispatch_interface
  from networkx.utils import edges_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_intersection() without return types