def _find_additional_rules_to_remove(seed_rules, current_rules, candidate_rule,
                                     config):
  """Return other rules that `candidate_rule` enables removing."""
  # TODO(petershaw): This is an *extremely* ineffecient way of computing this.
  relevant_rules = _find_relevant_rules(current_rules, candidate_rule)
  # TODO(petershaw): Remove this hack after implementing a more effecient
  # implementation. For now, consider only the 10 shortest relevant rules.
  # TODO(linluqiu): This introduces randomness to grammar induction, which
  # seems to mostly affect SCAN MCD3 split. Might need to re-evaluate this.
  if len(relevant_rules) > 10:
    relevant_rules = sorted(
        relevant_rules, key=lambda x: len(x.source) + len(x.target))[:10]
  additional_rules_to_remove = set()
  for rule in relevant_rules:
    if rule in seed_rules:
      continue
    candidates = unification_utils.get_rule_unifiers(rule, candidate_rule,
                                                     config)
    for existing_rule in candidates:
      if existing_rule in current_rules:
        additional_rules_to_remove.add(rule)
  return additional_rules_to_remove
Return other rules that `candidate_rule` enables removing.
language/compgen/csl/induction/greedy_policy.py