def _sparse_tensor_to_numpy_dict(
    sparse_tensor):
  """Convert a tf.SparseTensor into a dictionary of numpy arrays.

  Args:
    sparse_tensor: A SparseTensor of the trained relation.

  Returns:
    A dictionary representing the data.
  """
  return {
      'shape': sparse_tensor.dense_shape,
      'rows': numpy.array(sparse_tensor.indices[:, 0]),
      'cols': numpy.array(sparse_tensor.indices[:, 1]),
      'values': numpy.array(sparse_tensor.values)
  }
Convert a tf.SparseTensor into a dictionary of numpy arrays.

  Args:
    sparse_tensor: A SparseTensor of the trained relation.

  Returns:
    A dictionary representing the data.
  
language/nql/nql/io.py