def tokenize(tokenizer, data, max_length = 128):
    """
    Iterate over the data and tokenize it. Sequences longer than max_length are trimmed.
    :param tokenizer: tokenizer to use for tokenization
    :param data: list of sentences
    :return: a list of the entire tokenized data
    """
    tokenized_data = []
    for sent in data:
        tokens = tokenizer.encode(sent, add_special_tokens=True)
        # keeping a maximum length of bert tokens: 512
        tokenized_data.append(tokens[:max_length])
    return tokenized_data