DataCollatorForWholeWordMask does not handle numpy inputs when return_tensors="tf"
Author: dwyatte
Pull request: no

### System Info

- `transformers` version: 4.26.1
- Platform: macOS-13.2.1-x86_64-i386-64bit
- Python version: 3.9.16
- Huggingface_hub version: 0.12.1
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.11.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@gante @Rocketknight1

### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

```
import numpy as np
from transformers import AutoTokenizer, DataCollatorForWholeWordMask


features = [{"input_ids": np.array(list(range(10)))}, {"input_ids": np.array(list(range(10)))}]
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
data_collator =  DataCollatorForWholeWordMask(tokenizer, return_tensors="tf")

batch = data_collator(features)
```

```
InvalidArgumentError                      Traceback (most recent call last)
Cell In[1], line 9
      6 tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
      7 data_collator =  DataCollatorForWholeWordMask(tokenizer, return_tensors="tf")
----> 9 batch = data_collator(features)

File ~/venv/lib/python3.9/site-packages/transformers/data/data_collator.py:43, in DataCollatorMixin.__call__(self, features, return_tensors)
     41     return_tensors = self.return_tensors
     42 if return_tensors == "tf":
---> 43     return self.tf_call(features)
     44 elif return_tensors == "pt":
     45     return self.torch_call(features)

File ~/venv/lib/python3.9/site-packages/transformers/data/data_collator.py:912, in DataCollatorForWholeWordMask.tf_call(self, examples)
    910     mask_labels.append(self._whole_word_mask(ref_tokens))
    911 batch_mask = _tf_collate_batch(mask_labels, self.tokenizer, pad_to_multiple_of=self.pad_to_multiple_of)
--> 912 inputs, labels = self.tf_mask_tokens(batch_input, batch_mask)
    913 return {"input_ids": inputs, "labels": labels}

File ~/venv/lib/python3.9/site-packages/transformers/data/data_collator.py:1067, in DataCollatorForWholeWordMask.tf_mask_tokens(self, inputs, mask_labels)
   1065 indices_random = self.tf_bernoulli(input_shape, 0.1) & masked_indices & ~indices_replaced
   1066 random_words = tf.random.uniform(input_shape, maxval=len(self.tokenizer), dtype=tf.int64)
-> 1067 inputs = tf.where(indices_random, random_words, inputs)
   1069 # The rest of the time (10% of the time) we keep the masked input tokens unchanged
   1070 return inputs, labels

File ~/venv/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    151 except Exception as e:
    152   filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153   raise e.with_traceback(filtered_tb) from None
    154 finally:
    155   del filtered_tb

File ~/venv/lib/python3.9/site-packages/tensorflow/python/framework/ops.py:7215, in raise_from_not_ok_status(e, name)
   7213 def raise_from_not_ok_status(e, name):
   7214   e.message += (" name: " + name if name is not None else "")
-> 7215   raise core._status_to_exception(e) from None

InvalidArgumentError: cannot compute SelectV2 as input #2(zero-based) was expected to be a int64 tensor but is a int32 tensor [Op:SelectV2]
```

### Expected behavior

No exception.

This is a pretty simple bug. Seems we just need to cast the inputs to tf.int64 [here](https://github.com/huggingface/transformers/blob/b338414e614a30af5f940269484ef15bf716d078/src/transformers/data/data_collator.py#L910) which we do in `DataCollatorForLanguageModeling` but not `DataCollatorForWholeWordMask`

This is necessary to use the data collator with https://github.com/huggingface/datasets `datasets.Dataset.to_tf_dataset` since it implicitly formats data as `numpy` causing it to come into the data collator as int32

Comments:
Hey @dwyatte 👋  

At a first glance, a missing `tf.cast` seems to be indeed the problem. Would you be interested in opening a PR with the fix? 🤗 

@gante sure thing, here you go: https://github.com/huggingface/transformers/pull/22032. Requested you for review