Dataset load train data have values but when training got num_examples 0
Author: lucasjinreal
Pull request: no

I have usinng load_dataset load data 

```
>> training data samples: 51184 400 ['input', 'output', 'input_ids', 'labels', 'attention_mask']
>> training data samples: 51184 400 ['input', 'output', 'input_ids', 'labels', 'attention_mask'] 
```

it actually have values, not 0, but training I got error:

```
IndexError: Invalid key: 38100 is out of bounds for size 0
```

And the training info:

```
***** Running training *****
  Num examples = 0
  Num Epochs = 3
  Instantaneous batch size per device = 2
  Total train batch size (w. parallel, distributed & accumulation) = 128
  Gradient Accumulation steps = 32
  Total optimization steps = 1,197
  Number of trainable parameters = 19,988,480
```

Why nuim examples got 0?

the training examples logged are actually normal:

```
>>> tokenizer example: [1, 450, 1494, 338, 263, 14983, 1546, 385, 319, 29902, 20255, 2000, 4007, 22137, 322, 263, 5199, 1404, 2000, 4911, 29889, 450, 20255, 338, 13052, 296, 29892, 7134, 519, 322, 1248, 568, 304, 1234, 5155, 310, 1404, 29889, 13, 13, 2659, 29901, 235, 178, 169, 234, 190, 137, 233, 146, 146, 235, 194, 179, 30287, 30557, 30847, 31502, 30768, 31138, 30783, 31529, 31629, 30354, 30505, 30413, 30980, 30594, 31016, 30503, 30413, 30980, 30874, 232, 193, 135, 30429, 30210, 31462, 30705, 31174, 30448, 234, 170, 178, 30748, 30805, 31466, 31565, 31935, 234, 181, 149, 31412, 31138, 31951, 31217, 30874, 232, 193, 135, 30210, 233, 169, 133, 234, 145, 138, 13, 13, 7900, 22137, 29901, 30783, 31529, 31629, 30354, 30505, 30413, 30980, 30594, 31016, 30503, 30413, 30980, 30874, 232, 193, 135, 30429, 30210, 31462, 30705, 31174, 30448, 234, 170, 178, 30748, 30805, 31466, 31565, 31935, 234, 181, 149, 31412, 31138, 31951, 31217, 30874, 232, 193, 135, 30210, 233, 169, 133, 234, 145, 138, 30214, 30392, 31180, 30319, 31074, 30415, 30275, 30874, 232, 193, 135, 234, 170, 178, 30748, 30545, 30210, 31359, 30346, 30667, 30687, 30267, 13, 13, 31529, 31629, 30354, 30392, 31180, 30319, 31074, 30415, 30275, 30406, 30805, 233, 146, 146, 235, 194, 179, 31935, 234, 181, 149, 31531, 31613, 30210, 30354, 30415, 31629, 30354, 30267, 232, 177, 134, 30682, 30651, 30406, 30805, 31466, 31565, 31935, 234, 181, 149, 30505, 233, 162, 147, 30287, 30594, 232, 139, 190, 30210, 233, 169, 133, 234, 145, 138, 30748, 31454, 30214, 31594, 31325, 31835, 30495, 31935, 234, 181, 149, 30682, 30815, 30505, 232, 150, 173, 30755, 30544, 31424, 30267, 31529, 31629, 30354, 236, 157, 146, 234, 160, 131, 30594, 31016, 31462, 30705, 30214, 31570, 31389, 30682, 30651, 30406, 30805, 233, 146, 146, 235, 194, 179, 31935, 234, 181, 149, 30505, 30594, 31016, 30429, 30210, 31462, 30705, 30267, 13, 13, 30874, 232, 193, 135, 234, 170, 178, 30748, 30545, 31107, 30406, 31529, 31629, 30354, 236, 157, 146, 30594, 31016, 31462, 30705, 30210, 31141, 30952, 30214, 30768, 31138, 30783, 31529, 31629, 30354, 30505, 30413, 30980, 30594, 31016, 30503, 30413, 30980, 30874, 232, 193, 135, 30429, 30210, 31462, 30705, 31174, 30448, 234, 170, 178, 30748, 30805, 31466, 31565, 31935, 234, 181, 149, 31412, 31138, 31951, 31217, 30874, 232, 193, 135, 30210, 233, 169, 133, 234, 145, 138, 30267, 13, 13, 232, 136, 186, 30988, 30805, 31639, 30214, 30672, 31381, 30682, 30651, 233, 141, 141, 30874, 232, 193, 135, 234, 170, 178, 30748, 30748, 30573, 31977, 30502, 233, 176, 168, 236, 173, 167, 30383, 13, 13, 29896, 29889, 29871, 30783, 31529, 31629, 30354, 30505, 31951, 31217, 30874, 232, 193, 135, 30429, 30210, 31462, 30705, 31174, 30448, 234, 170, 178, 30748, 30267, 30810, 30682, 30651, 30768, 31138, 30783, 31529, 31629, 30354, 30505, 31951, 31217, 30874, 232, 193, 135, 30429, 30210, 30683, 30959, 31174, 30448, 234, 170, 178, 30748, 30805, 31195, 31424, 30267, 13, 29906, 29889, 29871, 30783, 31951, 31217, 30874, 232, 193, 135, 30429, 30210, 234, 170, 178, 30748, 30959, 31733, 30936, 31174, 30448, 234, 170, 178, 30748, 30214, 31466, 31565, 30544, 30505, 31951, 30502, 30594, 31016, 30940, 30429, 31935, 234, 181, 149, 31412, 31138, 31951, 31217, 30874, 232, 193, 135, 30210, 233, 169, 133, 234, 145, 138, 30267, 13, 13, 30768, 31138, 30810, 31977, 30502, 233, 176, 168, 236, 173, 167, 30214, 30672, 31381, 31238, 30682, 30651, 31466, 31565, 30544, 31935, 234, 181, 149, 31412, 31138, 31951, 31217, 30874, 232, 193, 135, 30210, 233, 169, 133, 30267, 30878, 30822, 30214, 30672, 31381, 30682, 30651, 31419, 235, 193, 134, 30810, 31959, 233, 169, 133, 234, 145, 138, 30214, 31666, 31333, 233, 142, 172, 233, 169, 133, 13, 13, 2659, 29901, 31201, 236, 138, 141, 30287, 30557, 31529, 31629, 30354, 13, 13, 7900, 22137, 29901, 31529, 31629, 30354, 30392, 31180, 30319, 31074, 30415, 30275, 30406, 30805, 233, 146, 146, 235, 194, 179, 31935, 234, 181, 149, 31531, 31613, 30210, 30354, 2]
```


Comments:
It's impossible for us to help you without knowinbg the code you run.

When I use **torch.compile(),** with PyTorch 2.0,  Trainer seems to remove all the columns in the datasets
(Pdb) [INFO|trainer.py:565] 2023-06-08 14:00:46,576 >> max_steps is given, it will override any value given in num_train_epochs
[INFO|trainer.py:622] 2023-06-08 14:00:46,576 >> Using cuda_amp half precision backend
[INFO|trainer.py:763] 2023-06-08 14:00:46,577 >> **The following columns in the training set don't have a corresponding argument in `OptimizedModule.forward` and have been ignored: output, input, attention_mask, input_ids, labels. If output, input, attention_mask, input_ids, labels are not expected by `OptimizedModule.forward`,  you can safely ignore this message**.
Loading checkpoint shards:   0%|                                                                                                                                                                                                                                                              | 0/2 [00:00<?, ?it/s]/home/jeff/anaconda3/envs/torch2.0/lib/python3.10/site-packages/transformers/optimization.py:407: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning
  warnings.warn(
[INFO|trainer.py:1779] 2023-06-08 14:00:51,297 >> ***** Running training *****
[INFO|trainer.py:1780] 2023-06-08 14:00:51,297 >>   Num examples = 0
[INFO|trainer.py:1781] 2023-06-08 14:00:51,297 >>   Num Epochs = 26
[INFO|trainer.py:1782] 2023-06-08 14:00:51,297 >>   Instantaneous batch size per device = 2
[INFO|trainer.py:1783] 2023-06-08 14:00:51,297 >>   Total train batch size (w. parallel, distributed & accumulation) = 128
[INFO|trainer.py:1784] 2023-06-08 14:00:51,297 >>   Gradient Accumulation steps = 16
[INFO|trainer.py:1785] 2023-06-08 14:00:51,297 >>   Total optimization steps = 4,000
[INFO|trainer.py:1786] 2023-06-08 14:00:51,298 >>   Number of trainable parameters = 1,767,049,216


updates: 
- when I remove **model=torch.compile(model)**, everything works well
- when I use **model=torch.compile(model)** with option **--remove_unused_columns False** , and remove useless unpad columns,  it comes with a new error **Dynamo only supports FSDP with use_orig_params=True**


The problem of the labels removes with `torch.compile` is being addressed in #24066 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.