def sample(self, score_fn=None):
    """Sample a source and target pair.

    Args:
      score_fn: A scoring function that takes parent_rule (QCFGRule), nt_idx,
        child_rule (QCFGRule) and returns s score.

    Returns:
      A tuple of source tokens and target tokens.
    """
    if not score_fn:
      score_fn = _uniform_score_fn
    root_rule = JointRule(parsing_utils.ROOT_RULE_KEY, frozenset())
    outputs = None
    while not outputs:
      try:
        outputs = self._expand({target_grammar.ROOT_SYMBOL},
                               score_fn,
                               root_rule,
                               0,
                               recursions=0)
      except ValueError as e:
        print(e)
    sources, targets = _convert_to_qcfg(outputs)
    return sources, targets
Sample a source and target pair.

    Args:
      score_fn: A scoring function that takes parent_rule (QCFGRule), nt_idx,
        child_rule (QCFGRule) and returns s score.

    Returns:
      A tuple of source tokens and target tokens.
    
language/compgen/csl/augment/joint_sampler.py