I think group_by_length feature can be faster using a namely length list
### Feature request

Current group_by_length requires ```lengths``` list that can be fully-loaded from dataset:
```
class Trainer:
...

    def _get_train_sampler(self) -> Optional[torch.utils.data.Sampler]:
    ...

        if self.args.group_by_length:
            if is_datasets_available() and isinstance(self.train_dataset, datasets.Dataset):
                lengths = (
                    self.train_dataset[self.args.length_column_name]
                    if self.args.length_column_name in self.train_dataset.column_names
                    else None
                )
```
For example, If I want to make lengths list with 'attention_mask' column, ```lengths``` list would be look like:
```
[[1,1,1,1,1],[1,1,1,1,1,1,1,1,1],[1,1,1] ...]
```
But If I want to use length information only, why can't I make this list like:
```
[5,9,3...] # length of each row
```
If I make this 'length file' before training with group_by_length feature, then the ```lengths``` list can be easily made by :

```
def appender(length):
    temp = []
    temp.append([1 for _ in range(length)])
    return temp

class customized_trainer(Trainer):
    def handle_group_by_length(self, filepath=''):
        with open(filepath,'r') as f:
            lengthsfile=json.load(f) # json or whatsoever

        import multiprocessing as mp
        pool = mp.Pool(6)
        lengths = pool.map(appender, lengthsfile)
        lengths = [ent for sublist in lengths for ent in sublist]

        self.lengths = lengths

```

```
trainer.handle_group_by_length('file.json') # this would load the length file
```

This reduced the loading time into about 1/10, 30 mins into 3 mins for me. 

### Motivation

While I tried to train with ~25GB text dataset, this code required about 30 minutes to load ```lengths``` list.
I found that loading full column in the group_by_length feature is the problem.
So I changed the code to load much smaller dataset - column length list - and It worked.


### Your contribution

This would require users to make "row length list file' before training. So I'm not that assertive to this proposal. 
cc @sgugger <|||||>As explained in the documentation, you should provide the `lengths` column in the dataset. If you use the `Dataset.map` method to build it, you won't need to implement any multiprocessing since it will do it for you. It will also cache the result so you only need to the computation once.