The problem lies in your added line:
toy_dataset = IMDbDataset(train_encodings[:n_toy], y_binary_train[:n_toy])

The train_encodings is a dictionary (with some added properties that let you take a slice like this) so you should do some thing like
toy_encodings = {k: v[:n_toy] for k, v in train_encodings.items()}

to keep a dictionary.