code: def test_to_numpy_array_structured_dtype_attrs_from_fields(
      G, expected
  ):
      """When `dtype` is structured (i.e. has names) and `weight` is None, use
      the named fields of the dtype to look up edge attributes."""
      G.add_edge(0, 1, weight=10, cost=5.0)
      dtype = np.dtype([("weight", int), ("cost", int)])
      A = nx.to_numpy_array(G, dtype=dtype, weight=None)
      expected = np.asarray(expected, dtype=dtype)
      npt.assert_array_equal(A, expected)
  
imports: import pytest
  import networkx
  from networkx.generators.classic import barbell_graph, cycle_graph, path_graph
  from networkx.utils import graphs_equal
label_desc: Use image node_id 7 for calling a global function with example usage: test_to_numpy_array_structured_dtype_attrs_from_fields(G, expected) without return types