def get_tf_tensor(self, rel_name):
    """Get the Tensor that represents a relation.

    Args:
      rel_name: string naming a declared relation

    Returns:
      tf.SparseTensor

    Raises:
      RuntimeError: If the expression has no initial value.
    """
    if rel_name not in self._cached_tensor:
      if rel_name not in self._np_initval:
        raise RuntimeError('KG relation named %r has no initial value.' %
                           rel_name)
      m = self._np_initval[rel_name]
      if self.is_dense(rel_name):
        self._cached_tensor[rel_name] = tf.Variable(
            m, trainable=self.is_trainable(rel_name), name='nql/' + rel_name)
        self._initializers.append(self._cached_tensor[rel_name].initializer)

      else:
        data_m = np.transpose(np.vstack([m.row, m.col]))
        if not self.is_trainable(rel_name):
          sparse_tensor = tf.SparseTensor(data_m, m.data, m.shape)
        else:
          data_var_name = 'nql/%s_values' % rel_name
          data_var = tf.Variable(m.data, trainable=True, name=data_var_name)
          self._initializers.append(data_var.initializer)
          sparse_tensor = tf.SparseTensor(data_m, data_var, m.shape)
          self._declaration[rel_name].underlying_parameter = data_var
        self._cached_tensor[rel_name] = (sparse_tensor.indices,
                                         sparse_tensor.values,
                                         sparse_tensor.dense_shape)
    if self.is_dense(rel_name):
      return self._cached_tensor[rel_name]  # pytype: disable=bad-return-type
    else:
      return tf.SparseTensor(
          indices=self._cached_tensor[rel_name][0],
          values=self._cached_tensor[rel_name][1],
          dense_shape=self._cached_tensor[rel_name][2],
      )
Get the Tensor that represents a relation.

    Args:
      rel_name: string naming a declared relation

    Returns:
      tf.SparseTensor

    Raises:
      RuntimeError: If the expression has no initial value.
    
language/nql/nql/__init__.py