def trim_tokens(file_token_list, max_tokens):
    """
    If given list has more than given max_tokens, return an even split between the head and tail of the
    list so that total number of tokens is max_tokens.
    :param file_token_list: the tokens to check.
    :param max_tokens: max number of tokens to return as a list.
    :return:
    """
    ntokens = len(file_token_list)
    if ntokens > max_tokens:
        cut_out = ntokens - max_tokens
        front_end_offset = int(max_tokens/2)
        back_begin_offset = front_end_offset + cut_out
        file_token_list = file_token_list[:front_end_offset] + file_token_list[back_begin_offset:]
    return file_token_list