def test_output_values(
      self, use_edges, use_nodes, use_globals, edges_reducer, nodes_reducer):
    """Compares the output of a GlobalBlock to an explicit computation."""
    input_graph = self._get_input_graph()
    global_block = blocks.GlobalBlock(
        global_model_fn=self._global_model_fn,
        use_edges=use_edges,
        use_nodes=use_nodes,
        use_globals=use_globals,
        edges_reducer=edges_reducer,
        nodes_reducer=nodes_reducer)
    output_graph = global_block(input_graph)

    model_inputs = []
    if use_edges:
      model_inputs.append(
          blocks.EdgesToGlobalsAggregator(edges_reducer)(input_graph))
    if use_nodes:
      model_inputs.append(
          blocks.NodesToGlobalsAggregator(nodes_reducer)(input_graph))
    if use_globals:
      model_inputs.append(input_graph.globals)

    model_inputs = tf.concat(model_inputs, axis=-1)
    self.assertIs(input_graph.edges, output_graph.edges)
    self.assertIs(input_graph.nodes, output_graph.nodes)

    output_graph_out = utils_tf.nest_to_numpy(output_graph)
    model_inputs_out = model_inputs

    expected_output_globals = model_inputs_out * self._scale
    self.assertNDArrayNear(
        expected_output_globals, output_graph_out.globals, err=1e-4)
Compares the output of a GlobalBlock to an explicit computation.
graph_nets/tests_tf2/blocks_test.py