DataCollatorForLanguageModeling should allow users to send there own labels
Author: yonigottesman
Pull request: no
Labels: name: Feature request

### Feature request

when calling this collate function the labels are always calculated like this:
`labels = batch["input_ids"].clone()`
but in some cases the user wants to customize the labels. For examples when training on conversational inputs I might want to put -100 on user parts of the conversation. 
When #30650 is merged,  we will be able to compute the labels easily and the inputs can include `labels` in the dictionary next to `input_ids` in these cases the collate should just do the padding on the labels like everything else and keep the user labels without doing the clone

### Motivation

related to #30650

### Your contribution

ill implement this if you guys think its a good idea :) 

Comments:
Seems like the `DataCollatorForLanguageModeling` doesn't do anything special apart from padding and cloning labels, so a simple `DataCollatorWithPadding` might work if we modify the `pad` function to pad also the labels. In fact I also encountered the same issue when trying to pass my own labels.

So +1 from me to allow users pass labels, and pad them with `DataCollatorWithPadding`

Also, the chat part sounds very similar to the [`DataCollatorForCompletionOnlyLM` from TRL library](https://github.com/huggingface/trl/blob/a57e75967c2b787f42f4e402ed7ca23cd9bad9a9/trl/trainer/utils.py#L115) :)

So you suggest a new collate class `DataCollatorWithPadding`? that does the same as DataCollatorForLanguageModeling but doesnt clone labels?
I think we should stick with DataCollatorForLanguageModeling as it already pads all other inputs it just treats `labels` differently. 

No, I'm not suggesting any new class but to modify the tokenizer's underlying `pad` function so that it pads also the labels. I think in that case users can pass their own input ids + labels, while the collator only does the padding. Since `DataCollatorWithPadding` already exists, thought it might be easier this way in case there are many ways of creating labels (not only the conversational one)

Modifying `DataCollatorForLanguageModeling` also sounds good in case we want to create labels from input-ids and put -100 on other parts 😄 

ohhh i missed the `DataCollatorWithPadding` :scream: 
ill look into the tokenizer pad function...

ok i see its deep in the tokenizer pad [here](https://github.com/huggingface/transformers/blob/main/src/transformers/tokenization_utils_base.py#L3817) that only padds `token_type_ids` `attention_mask` and `input_ids`.
Closing this issue and maybe later I can think of a way to make the `pad` more generic to support other keys as well.
For now a quick workaround is to ride on the `special_tokens_mask`:
```
@dataclass
class LabelsDataCollatorWithPadding:

    tokenizer: PreTrainedTokenizerBase
    padding: Union[bool, str, PaddingStrategy] = True
    max_length: Optional[int] = None
    pad_to_multiple_of: Optional[int] = None
    return_tensors: str = "pt"

    def __call__(self, features):
        for i in features:
            i["special_tokens_mask"] = i["labels"]
            del i["labels"]

        batch = pad_without_fast_tokenizer_warning(
            self.tokenizer,
            features,
            padding=self.padding,
            max_length=self.max_length,
            pad_to_multiple_of=self.pad_to_multiple_of,
            return_tensors=self.return_tensors,
        )
        batch["labels"] = batch["special_tokens_mask"]
        return batch
```