def preprocess_function(examples, tokenizer, max_length=512):
    """
    This function is used to tokenized text in datasets
    Adopt by me almost without changes from https://github.com/huggingface/notebooks/blob/master/examples/summarization.ipynb
    :param examples: dataset
    :param tokenizer: tokenizer to use
    :param max_length: max length of sequence in tokens
    :return:
    """
    inputs = [doc for doc in examples["text"]]
    model_inputs = tokenizer(inputs, max_length=max_length, truncation=True, padding="max_length")

    # Setup the tokenizer for targets
    with tokenizer.as_target_tokenizer():
        labels = tokenizer(examples["summary"], max_length=max_length, truncation=True, padding="max_length")

    model_inputs["labels"] = labels["input_ids"]
    return model_inputs