import re


def max_length(df, tokenizer):
    """Determine the max length of an example.

    Args:
            df: Panda dataframe containing examples.
            tokenizer: An instance of the relevant tokenizer.
    """
    max_len = 0
    examples = df.example.values

    for example in examples:
        tokenized = tokenizer(re.split("\.\s+", example.rstrip(".").strip()), add_special_tokens=True)
        segments  = tokenized['input_ids']
        for segment in segments:
            max_len = max(max_len, len(segment))

    return max_len