UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow
### System Info

System Info
nvidia CUDA Version: 12.1,  Driver Version: 525.105.17
transformers-cli env is
- `transformers` version: 4.29.2
- Platform: Linux-4.19.87-netease6-1-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.14.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.1.0a0+fe05266 (True)



### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

when i use tokenizer(...,padding=True), i will get a warnning : "UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor."  and this function latency is 0.744675874710083  if query_list over 800 words .
```
st = time.time()
inputs = tokenizer(query_list, return_tensors="pt" ,padding=True)
print(time.time() - st)
```


### Expected behavior

Reduce latency and fix the  UserWarning.
@liucw2012  Thank you for the opening the issue and PR!

I haven't check the PR in detail, but I am wondering what's the **total time** if you convert it to numpy first + numpy to torch tensor.

Also a remark: when giving a code snippet, please provide all the necessary  variable value so it could run directly.
(I know, the above one is simple enough, but it's a good thing to provide, thank you!)<|||||>@ydshieh 
the latency is 0.0147s  if convert it to numpy.<|||||>The speed looks very good. But see my comment in the PR :-)<|||||>@ydshieh 
i have another pr . it's already went through a lot checks. but i don't know is it accepted or what should i do next. 
could u give a review pls ?
https://github.com/huggingface/transformers/pull/24772#issuecomment-1635168756<|||||>Thank you @liucw2012 for the PR ❤️ 

The CI in that PR is green 🚀 . However I would like to check a bit deeper what the (nested) inputs would be possible for that method, and if every case works and if none of the case will slow down.<|||||>BTW, could you maybe provide what `query_list` you used.

(it's always a nice thing to provide the actual definition for variables in a code snippet 🙏 )<|||||>sorry, i  was a lit bit busy recently. the query_list  is just  two chats, each one is almost 800 Chinese characters。all others examples is ok if u used tokenier with padding=true；<|||||>It's fine. But see

https://github.com/huggingface/transformers/pull/24772#discussion_r1265559341