def remove_graphs_tuple_padding(padded_graphs_tuple, valid_size):
  """Strips a padded `GraphsTuple` of padding.

  Given a graph that has been padded by `padding` amount, remove the padding
  to recover the original graph.

  Often used in the sequence:
  ```
    graphs_tuple_size = get_graphs_tuple_size(graphs_tuple)
    padded_graphs_tuple = pad_graphs_tuple(graphs_tuple,
                                           pad_nodes_to=x,
                                           pad_edges_to=y,
                                           pad_graphs_to=z)
    unpadded_graphs_tuple = remove_graphs_tuple_padding(padded_graphs_tuple,
                                                        graphs_tuple_size)
  ```


  Args:
    padded_graphs_tuple: A `graphs.GraphsTuple` that has been padded by
      `padding` amount.
    valid_size: A `GraphsTupleSize` that represents the size of the valid graph.

  Returns:
    Returns a `graphs.GraphsTuple` which is padded_graphs_tuple stripped of
      padding.
  """
  stripped_graph_kwargs = {}
  graph_dict = padded_graphs_tuple._asdict()  # pylint: disable=protected-access

  for field, tensor_nest in graph_dict.items():
    field_valid_size = _get_field_size_from_size_tuple(valid_size, field)
    strip_fn = lambda x: x[:field_valid_size]  # pylint:disable=cell-var-from-loop
    stripped_field = tree.map_structure(strip_fn, tensor_nest)
    stripped_graph_kwargs[field] = stripped_field
  return graphs.GraphsTuple(**stripped_graph_kwargs)
Strips a padded `GraphsTuple` of padding.

  Given a graph that has been padded by `padding` amount, remove the padding
  to recover the original graph.

  Often used in the sequence:
  ```
    graphs_tuple_size = get_graphs_tuple_size(graphs_tuple)
    padded_graphs_tuple = pad_graphs_tuple(graphs_tuple,
                                           pad_nodes_to=x,
                                           pad_edges_to=y,
                                           pad_graphs_to=z)
    unpadded_graphs_tuple = remove_graphs_tuple_padding(padded_graphs_tuple,
                                                        graphs_tuple_size)
  ```


  Args:
    padded_graphs_tuple: A `graphs.GraphsTuple` that has been padded by
      `padding` amount.
    valid_size: A `GraphsTupleSize` that represents the size of the valid graph.

  Returns:
    Returns a `graphs.GraphsTuple` which is padded_graphs_tuple stripped of
      padding.
  
graph_nets/utils_tf.py