def as_weighted_triples(self, rel_name,
                          m):
    """Make the value of a SparseTensor for a relation human-readable.

    The human-readable format is a dictionary mapping tuples of strings
    (rel_name,subject_entity,object_entity) to weights.

    Args:
      rel_name: a string naming a relation
      m: a tf.SparseTensor object

    Returns:
      a dictionary
    """
    nnz = m.indices.shape[0]

    def as_domain_sym(entity_id):
      return self.get_entity_name(entity_id, self.get_domain(rel_name))

    def as_range_sym(entity_id):
      return self.get_entity_name(entity_id, self.get_range(rel_name))

    def triple(k):
      return (rel_name, as_domain_sym(m.indices[1, k]),
              as_range_sym(m.indices[0, k]))

    keys = [triple(i) for i in range(nnz)]
    vals = [m.values[i] for i in range(nnz)]
    return dict(zip(keys, vals))
Make the value of a SparseTensor for a relation human-readable.

    The human-readable format is a dictionary mapping tuples of strings
    (rel_name,subject_entity,object_entity) to weights.

    Args:
      rel_name: a string naming a relation
      m: a tf.SparseTensor object

    Returns:
      a dictionary
    
language/nql/nql/__init__.py