Thanks for your reply!  I passed “res” in a list in my little bit of test code there because I thought that was expected in line 343 of data_collator.py based on the stack trace for when I just passed the BatchEncoding object “res”:
collated = data_collator(res)


/usr/local/lib/python3.7/dist-packages/transformers/data/data_collator.py in __call__(self, examples)
    341     ) -> Dict[str, torch.Tensor]:
    342         # Handle dict or lists with proper padding and conversion to tensor.
--> 343         if isinstance(examples[0], (dict, BatchEncoding)):
    344             batch = self.tokenizer.pad(examples, return_tensors="pt", pad_to_multiple_of=self.pad_to_multiple_of)
    345         else:

/usr/local/lib/python3.7/dist-packages/transformers/tokenization_utils_base.py in __getitem__(self, item)
    234         else:
    235             raise KeyError(
--> 236                 "Indexing with integers (to access backend Encoding for a given batch index) "
    237                 "is not available when using Python based tokenizers"
    238             )

KeyError: 'Indexing with integers (to access backend Encoding for a given batch index) is not available when using Python based tokenizers'

This^^ surprised me a little bit because I thought the __call__ method of the datacollator accepted a BatchEncoding directly.
But maybe these issues with what to pass to the data collator are not the heart of my problem.
I think the main question is whether or not the tokenization that I am returning in __getitem__ for my dataset class is going to return batches in a format that the data collator and the rest of the trainer pipeline can use. I had thought that what was best for the DataCollatorForLanguageModeling was a BatchEncoding that has the [‘special_tokens_mask’] key based on the note in the docs: Data Collator — transformers 4.5.0.dev0 documentation
I have tried returning it with and without the special tokens mask and with and without padding and get the same “too many items to unpack” error in the forward() method as in my original post.