Remove unnessary `requests` module
Author: CoderTCY
Pull request: no
Labels: name: Feature request

name: for_v5?

### Feature request

Remove the `requests` module in the setup.py
https://github.com/huggingface/transformers/blob/dfe6e4c0efe47a4e0770b346a332f4a3423e7ca7/setup.py#L399-L411


### Motivation

After https://github.com/huggingface/transformers/pull/40889, Transformers had turned to `httpx` for core logic about network, so the `requests` should be depreciated.

### Your contribution

Remove it from `install_requires` and clean up the left requests calling in core logic.

Comments:
@wauplin @CoderTCY do either of you want to take this one? If not I'll mark it as a good first/second issue for other users!

hey @Rocketknight1 can i work on this?

@Rocketknight1 there are 3 main types of files where `requests` is used - 
1. `convert` scripts in `src/transformers`
2. tests
3. docstrings

What is the scope of this issue?

Also, replacing common logic is really easy, but it's the images/streaming part which is tedious. 
 the equivalent of 
```python
image = Image.open(requests.get(url, stream=True).raw)
```
using httpx is   

```python
with httpx.stream("GET", url) as response:
    image = Image.open(BytesIO(response.read()))
```
Do we want to use this everywhere? considering we need to add a generator and extra import (`BytesIO`) ?

thanks!

References for streaming behaviour - [source 1](https://www.python-httpx.org/compatibility/#streaming-responses), [source 2](https://github.com/encode/httpx/discussions/2296), but yeah i tested the above snippet and it works. We need to use `BytesIO` because `httpx` returns bytes, not a file-like object. 

> [@Rocketknight1](https://github.com/Rocketknight1) there are 3 main types of files where `requests` is used -
> 
> 1. `convert` scripts in `src/transformers`
> 2. tests
> 3. docstrings
> 
> What is the scope of this issue?
> 
> Also, replacing common logic is really easy, but it's the images/streaming part which is tedious. the equivalent of
> 
> image = Image.open(requests.get(url, stream=True).raw)
> using httpx is
> 
> with httpx.stream("GET", url) as response:
>     image = Image.open(BytesIO(response.read()))
> Do we want to use this everywhere? considering we need to add a generator and extra import (`BytesIO`) ?
> 
> thanks!

The `requests` in tests and docstrings can be kept (becauce this issue is intented to remove `requests` from dependencies).
Also, I prefer to add `io.BytesIO` import, but it's better to ask members.

@Rocketknight1 sorry I do believe it's a good issue to tackle for v5 but don't have the bandwidth to tackle it myself. Happy to review a PR though :) 

@omkar-334 @CoderTCY I think it'd be great to have separate PRs to keep things self-contained:
- 1 to remove the dependency by removing it from the code
- 1 to definitely remove from docstrings

> Also, I prefer to add `io.BytesIO` import, but it's better to ask members.

Noted, will go ahead with that..



> [@omkar-334](https://github.com/omkar-334) [@CoderTCY](https://github.com/CoderTCY) I think it'd be great to have separate PRs to keep things self-contained:
> 
> * 1 to remove the dependency by removing it from the code
> * 1 to definitely remove from docstrings

okay, got it. Working on this. 
I'll leave out the tests for now. 
thanks!

hey i've made a pr #42845