def _relations_roundtrip(self, use_fh=False):
    """Test full io pipeline on serializing relations.

    Very basic test that creates two sparse tensors, serializes them,
    deserializes them, then compares them using the transformation
    methods in io.

    Args:
      use_fh: Boolean indicating usage of FileLike instead of Filename.
    """
    sparse_tensor_dict = _make_sparse_tensor_dict()
    if use_fh:
      with open(self.filename, 'wb') as fh:
        io.write_sparse_tensor_dict(fh, sparse_tensor_dict)
      with open(self.filename, 'rb') as fh:
        io_sparse_matrix_dict = io.read_sparse_matrix_dict(fh)
    else:
      io.write_sparse_tensor_dict(self.filename, sparse_tensor_dict)
      io_sparse_matrix_dict = io.read_sparse_matrix_dict(self.filename)
    self.assertEqual(
        len(io_sparse_matrix_dict.keys()), len(sparse_tensor_dict.keys()))
    for rel_name, sparse_tensor in sparse_tensor_dict.items():
      ref_sparse_matrix = io._numpy_dict_to_sparse_matrix(
          io._sparse_tensor_to_numpy_dict(sparse_tensor))
      io_sparse_matrix = io_sparse_matrix_dict[rel_name]
      self.assertTrue(_equal_sparse(io_sparse_matrix, ref_sparse_matrix))
Test full io pipeline on serializing relations.

    Very basic test that creates two sparse tensors, serializes them,
    deserializes them, then compares them using the transformation
    methods in io.

    Args:
      use_fh: Boolean indicating usage of FileLike instead of Filename.
    
language/nql/nql/io_test.py