def get_output(self, source):
    """Returns (one-best target string, score) or (None, None)."""
    # Tokenize.
    tokens = source.split(" ")
    (wordpiece_ids, num_wordpieces, token_start_wp_idx,
     token_end_wp_idx) = tokenization_utils.get_wordpiece_inputs(
         tokens, self.tokenizer)
    wordpieces_batch = _convert_to_int_tensor(wordpiece_ids,
                                              self.config["max_num_wordpieces"])

    # Run encoder.
    wordpiece_encodings_batch = self.model.get_wordpiece_encodings(
        wordpieces_batch, [[num_wordpieces]])
    wordpiece_encodings = wordpiece_encodings_batch[0]

    # Create score_fn.
    score_fn = _get_score_fn(wordpiece_encodings, self.rules, self.model,
                             token_start_wp_idx, token_end_wp_idx)

    # Run parser.
    target_string, score = inference_parser.run_inference(
        source, self.rules, score_fn)

    # Validate target if target CFG provided.
    if (target_string and self.target_grammar_rules and
        not target_grammar.can_parse(target_string, self.target_grammar_rules)):
      if self.verbose:
        print("Invalid target: %s" % target_string)
      return None, None

    return target_string, score
Returns (one-best target string, score) or (None, None).
language/compgen/nqg/model/parser/inference/inference_wrapper.py