def _maybe_get_candidate_pair(source_c, source_b, target_c, target_b):
  """Returns candidate rule pair if proposed sources and targets are valid."""
  # Check that proposed sources and targets contain same non-terminal indexes.
  nts_c = _get_non_terminals(source_c)
  if nts_c != _get_non_terminals(target_c):
    return None

  nts_b = _get_non_terminals(source_b)
  if nts_b != _get_non_terminals(target_b):
    return None

  # Canonicalize non-terminal index ordering and return candidate pair.
  rule_c = _make_rule(nts_c, source_c, target_c)
  rule_b = _make_rule(nts_b, source_b, target_b)
  return (rule_c, rule_b)
Returns candidate rule pair if proposed sources and targets are valid.
language/compgen/csl/induction/unification_utils.py