def _follow_named_rel(self, rel_name,
                        inverted):
    """Follow a specific relation in the KG.

    Args:
      rel_name: a string naming a declared KG relation
      inverted: +1 to follow the relation normally, -1 to use inverses

    Returns:
      A NeuralQueryExpression
    """
    if inverted == +1:
      input_type_name = self.context.get_domain(rel_name)
      output_type_name = self.context.get_range(rel_name)
    else:
      if inverted != -1:
        raise ValueError('Inverted (%d) is neither +1 nor -1' % inverted)
      input_type_name = self.context.get_range(rel_name)
      output_type_name = self.context.get_domain(rel_name)
    m = self.context.get_tf_tensor(rel_name)
    m_is_sparse = not self.context.is_dense(rel_name)
    transpose_m = (inverted == -1)

    self._check_type_compatibility(input_type_name, self._type_name, 'follow')
    output_expr = matmul_any_tensor_dense_tensor(
        m, self.tf, a_is_sparse=m_is_sparse, transpose_a=transpose_m)
    provenance = NQExprProvenance(
        operation='follow', args=(rel_name, inverted), inner=self.provenance)
    return self.context.as_nql(output_expr, output_type_name, provenance)
Follow a specific relation in the KG.

    Args:
      rel_name: a string naming a declared KG relation
      inverted: +1 to follow the relation normally, -1 to use inverses

    Returns:
      A NeuralQueryExpression
    
language/nql/nql/__init__.py