def test_gradient_flow(self):
    """Verifies that gradient flow is as expected."""
    input_graph = self._get_input_graph()
    model = self._get_model()
    output_graph = model(input_graph)

    for input_field in ["nodes", "edges", "globals"]:
      input_tensor = getattr(input_graph, input_field)
      for output_field in ["nodes", "edges", "globals"]:
        output_tensor = getattr(output_graph, output_field)
        gradients = tf.gradients(output_tensor, input_tensor)
        if input_field == output_field:
          self.assertNotEqual(None, gradients[0])
        else:
          self.assertListEqual([None], gradients)
Verifies that gradient flow is as expected.
graph_nets/tests/modules_test.py