def get_answer(input_ids, tokenizer, start_pred, end_pred):
    """ function to extract the answer text from start and end index tokens """
    if start_pred == 0 or end_pred == 0 or end_pred < start_pred:
        return ''
    else:
        token_ids = input_ids.tolist()
        tokens = tokenizer.convert_ids_to_tokens(token_ids)
        answer = tokens[start_pred]
        for token_index in range(start_pred + 1, end_pred + 1):
            if tokens[token_index][0:2] == '##':
                answer += tokens[token_index][2:]
            else:
                answer += ' ' + tokens[token_index]
    return answer