def create_mapping(
    start_offsets: Sequence[int],
    end_offsets: Sequence[int],
    context_to_plaintext_offset: Sequence[int],
) -> Tuple[List[int], List[int]]:
  """Creates a mapping from context offsets to plaintext offsets.

  Args:
    start_offsets: List of offsets relative to a TyDi entry's `contexts`.
    end_offsets: List of offsets relative to a TyDi entry's `contexts`.
    context_to_plaintext_offset: Mapping `contexts` offsets to plaintext
      offsets.

  Returns:
    List of offsets relative to the original corpus plaintext.
  """

  plaintext_start_offsets = [
      context_to_plaintext_offset[i] if i >= 0 else -1 for i in start_offsets
  ]
  plaintext_end_offsets = [
      context_to_plaintext_offset[i] if i >= 0 else -1 for i in end_offsets
  ]
  return plaintext_start_offsets, plaintext_end_offsets
Creates a mapping from context offsets to plaintext offsets.

  Args:
    start_offsets: List of offsets relative to a TyDi entry's `contexts`.
    end_offsets: List of offsets relative to a TyDi entry's `contexts`.
    context_to_plaintext_offset: Mapping `contexts` offsets to plaintext
      offsets.

  Returns:
    List of offsets relative to the original corpus plaintext.
  
language/canine/tydiqa/preproc.py