code: def test_node_attributes():
      """Tests that node contraction preserves node attributes."""
      G = nx.cycle_graph(4)
      # Add some data to the two nodes being contracted.
      G.nodes[0]["foo"] = "bar"
      G.nodes[1]["baz"] = "xyzzy"
      actual = nx.contracted_nodes(G, 0, 1)
      # We expect that contracting the nodes 0 and 1 in C_4 yields K_3, but
      # with nodes labeled 0, 2, and 3, and with a -loop on 0.
      expected = nx.complete_graph(3)
      expected = nx.relabel_nodes(expected, {1: 2, 2: 3})
      expected.add_edge(0, 0)
      cdict = {1: {"baz": "xyzzy"}}
      expected.nodes[0].update({"foo": "bar", "contraction": cdict})
      assert nx.is_isomorphic(actual, expected)
      assert actual.nodes == expected.nodes
  
imports: import pytest
  import networkx
  from networkx.utils import arbitrary_element, edges_equal, nodes_equal
label_desc: Use image node_id 25 for calling a global function with example usage: test_node_attributes() without return types