When Pillow is not installed, importing from transformers.image_transforms raises an unclear NameError
Author: convoliution
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: macOS-11.6.8-x86_64-i386-64bit
- Python version: 3.10.8
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help?

@amyeroberts @NielsRogge

### Information

- [ ] 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

Steps to reproduce the behavior:

1. Create and activate clean Python environment 
   ```sh
   python3 -m venv venv
   source venv/bin/activate
   ```
2. Install `transformers` and its direct dependencies
   ```sh
   pip install transformers
   ```
3. Attempt to import `transformers.image_transforms` or [one of its publicly-documented members](https://huggingface.co/docs/transformers/internal/image_processing_utils#transformers.image_transforms.center_crop)
   ```sh
   python -c 'from transformers.image_transforms import center_crop'
   ```
4. Encounter a `NameError`
   ```
   None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
     File "/Users/miliu/venv/lib/python3.10/site-packages/transformers/image_transforms.py", line 51, in <module>
       def to_channel_dimension_format(image: np.ndarray, channel_dim: Union[ChannelDimension, str]) -> np.ndarray:
   NameError: name 'ChannelDimension' is not defined
   ```

### Expected behavior

Rather than a `NameError` on import (caused by [`to_channel_dimension_format()`'s signature type annotation containing `ChannelDimension`](https://github.com/huggingface/transformers/blob/7586a1a367f5974e099e1be2fa8a751aa766179f/src/transformers/image_transforms.py#L51), which is [conditionally imported](https://github.com/huggingface/transformers/blob/7586a1a367f5974e099e1be2fa8a751aa766179f/src/transformers/image_transforms.py#L29) only [when `PIL` is available](https://github.com/huggingface/transformers/blob/7586a1a367f5974e099e1be2fa8a751aa766179f/src/transformers/utils/import_utils.py#L566-L567)), I would've expected something like `transformers.rescale`'s user experience, where it helpfully recommends installing `Pillow` when one attempts to use it:

```python
>>> from transformers import rescale
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
>>> rescale()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/miliu/venv/lib/python3.10/site-packages/transformers/utils/dummy_vision_objects.py", line 14, in rescale
    requires_backends(rescale, ["vision"])
  File "/Users/miliu/venv/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 997, in requires_backends
    raise ImportError("".join(failed))
ImportError: 
rescale requires the PIL library but it was not found in your environment. You can install it with pip:
`pip install pillow`. Please note that you may need to restart your runtime after installation.
```

Comments:
cc @amyeroberts 

Thanks for raising @convoliution ! I agree both the imports and error message could be improved and your suggestion. 

It's highlighted another thing that needs to be addressed: adding center_crop to the `transformers` [module init](https://github.com/huggingface/transformers/blob/4f78bcb2871e0c51bec55edb87aadcaedce58069/src/transformers/__init__.py#L745). (I realised that if we import `rescale` using `from transformers.image_transforms import rescale` we get the same `ChannelDimension` error). 

I'll open up PRs to add to the init and to address the imports issue. 

^--- the second PR will need to be merged in to be fully resolved. 

Closing as the issue is now resolved: all image transforms can be safely imported and raise a clear error if Pillow is not installed in the environment if required. 

@convoliution Thanks again for raising. One change to note is that some transforms that were previously importable directly from `transformers` can now only be imported through the `image_transforms` module e.g.: 
`from transformers.image_transforms import rescale` c.f. #20704