def global_to_local_offset(json_dict, candidate_idx, byte_index):
  """Converts a byte index within the article to the byte offset within the candidate."""
  global_start = json_dict["passage_answer_candidates"][candidate_idx][
      "plaintext_start_byte"]
  return byte_index - global_start
Converts a byte index within the article to the byte offset within the candidate.
language/canine/tydiqa/data.py