self.encodings is a list (of dictionaries) and thus it does not have a .items() function. Taking a guess that X_text_tokenized contains all data and we need to index it to get one item, I think you need to update
item = {key: torch.tensor(val[idx]) for key, val in self.encodings.items()}

to
item = {key: torch.tensor(val) for key, val in self.encodings[idx].items()}