def _get_rule_size(rule, config):
  """Returns the "size" based on number of terminal and nonterminal tokens."""
  size = 0.0
  for token in rule.source + rule.target:
    if qcfg_rule.is_nt(token):
      size += config["non_terminal_coef"]
    else:
      size += config["terminal_coef"]
  return size
Returns the "size" based on number of terminal and nonterminal tokens.
language/compgen/csl/induction/objective_utils.py