Solved by AlekseyDorkin in post #3 
              
              
                An example collate function may look like this in your case: 
def collate_tokenize(data):
  text_batch = [element["text"] for element in data]
  tokenized = tokenizer(text_batch, padding='longest', truncation=True, return_tensors='pt')
  return tokenized

Then you pass to the dataloader: 
dataloader…