def update_tokenizer_model_max_length(tokenizer, max_position):
    """This function updates the position embedding length of a tokenizer to a new max position.

    Arguments:
        tokenizer: required: a transformer tokenizer
        max_position: required: an integer determining new position embedding size
    Return:
        tokenizer: updated tokenizer; in which model maximum length has been extended based on new size
    """

    tokenizer.model_max_length = max_position
    tokenizer.init_kwargs['model_max_length'] = max_position
    print(f'updated tokenizer model max imum length to {max_position}')

    return tokenizer