def _get_arity(source):
  """Return the arity of the rule."""
  nts = set(get_nts(source))
  nt_indices = [get_nt_index(nt) for nt in nts]
  arity = len(nts)
  if sorted(nt_indices) != list(range(1, arity + 1)):
    raise ValueError("Source is unnormalized: %s" % source)
  return arity
Return the arity of the rule.
language/compgen/csl/qcfg/qcfg_rule.py