def _get_inputs_targets(
      self,
      source_sentences,
      target_sentences,
      evidence,
  ):
    """Produces inputs / targets from sentences and evidence."""
    # Inputs and targets constructed by pasting together renderables.
    inputs_renderables = source_sentences.copy()
    targets_renderables = []

    # Regardless of task we need to know diff to determine updates. Also, we're
    # using only the text and stripping to avoid issues with delimiters and
    # whitespace.
    source_texts = [str(s.text).strip() for s in source_sentences]
    target_texts = [str(t.text).strip() for t in target_sentences]
    cruncher = difflib.SequenceMatcher(a=source_texts, b=target_texts)
    updated = []
    for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
      if tag in ("replace", "insert"):
        targets_renderables.extend(target_sentences[blo:bhi])
        updated.extend(target_sentences[blo:bhi])
      elif tag == "equal":
        if self.task == Task.fullgen:
          targets_renderables.extend(target_sentences[blo:bhi])
        else:
          targets_renderables.extend(
              s.delimiter for s in source_sentences[alo:ahi])
      elif tag == "delete":
        continue
    if self.filter_no_diff and not updated:
      return

    # Add context
    inputs_renderables.append(CONTEXT_MARKER)
    inputs_temp = render_all(inputs_renderables)
    input_length = self._get_length(inputs_temp)
    for e in evidence:
      evidence_length = self._get_length(str(e))
      if input_length + evidence_length > self.max_input_length:
        continue
      # Check if evidence supports an update
      is_support = False
      for u in updated:
        if u.entity_ids & e.entity_ids:
          u.evidence.append(e)
          is_support = True
      if (is_support and self.include_evidence) or self.include_distractors:
        inputs_renderables.append(e)
      input_length += evidence_length

    inputs = render_all(inputs_renderables)
    targets = render_all(targets_renderables)

    yield {"inputs": inputs, "targets": targets}
Produces inputs / targets from sentences and evidence.
language/fruit/rendering_utils.py