def METHOD_NAME(example: Example):
    """
    Converts the target start/end positions from bytes to character offsets.
    """
    context = example['document_plaintext']
    context_bytes = context.encode('utf-8')
    for i in range(len(example['target']['passage_indices'])):
        pidx = example['target']['passage_indices'][i]
        if pidx == -1 or example['target']['start_positions'][i] == -1:
            continue
        example['target']['start_positions'][i] = len(
            context_bytes[:example['target']['start_positions'][i]].decode('utf-8', errors='replace'))
        example['target']['end_positions'][i] = len(
            context_bytes[:example['target']['end_positions'][i]].decode('utf-8', errors='replace'))
    num_passages = len(example['passage_candidates']['start_positions'])
    for i in range(num_passages):
        passage_start_position = example['passage_candidates']['start_positions'][i]
        passage_end_position = example['passage_candidates']['end_positions'][i]
        example['passage_candidates']['start_positions'][i] = len(
            context_bytes[:passage_start_position].decode('utf-8', errors='replace'))
        example['passage_candidates']['end_positions'][i] = len(
            context_bytes[:passage_end_position].decode('utf-8', errors='replace'))
    example['context'] = [context]
    return example