code: def test_weighted(self):
      G = nx.Graph()
      nx.add_cycle(G, range(7), weight=2)
      ans = nx.average_shortest_path_length(G, weight="weight")
      assert ans == pytest.approx(4, abs=1e-7)
      G = nx.Graph()
      nx.add_path(G, range(5), weight=2)
      ans = nx.average_shortest_path_length(G, weight="weight")
      assert ans == pytest.approx(4, abs=1e-7)
  
imports: import pytest
  import networkx
label_desc: Use image node_id 3 for calling the TestAverageShortestPathLength obj's underlying member method code with example usage: obj.test_weighted() without return types