

TITLE
AutoFeatureExtractor not respecting override parameters (for LayoutLMv2FeatureExtractor)

COMMENTS
2

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
### System Info

```shell
- `transformers` version: 4.17.0 - (but checked issue is still present on `main` branch)
- Platform: Linux-4.14.262-200.489.amzn2.x86_64-x86_64-with-glibc2.10
- Python version: 3.8.10
- PyTorch version (GPU?): 1.10.2+cu113 (True)
- 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?: Yes
- Using distributed or parallel set-up in script?: Yes
```


### Who can help?

@NielsRogge

### Information

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

### Tasks

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

### Reproduction

1. In any environment without `pytesseract` installed
2. Create an `AutoFeatureExtractor` for LayoutLMv2, specifying an override that `apply_ocr = False`:

```
from transformers import AutoFeatureExtractor
feature_extractor = AutoFeatureExtractor.from_pretrained(
    "microsoft/layoutlmv2-base-uncased",
    apply_ocr=False,
)
```

Because [FeatureExtractionMixin.from_dict()](https://github.com/huggingface/transformers/blob/e1c153cbaa2f4dc6fa10aec8e3afb38c1b437947/src/transformers/feature_extraction_utils.py#L490) first creates the instance with *only* the configuration dict (in which `apply_ocr` defaults to `True`) and then **updates** the override parameters on the object, this still hits the `pytesseract` install check and fails with:

```
ImportError: 
LayoutLMv2FeatureExtractor requires the PyTesseract library but it was not found in your environment. You can install it with pip:
`pip install pytesseract`
```

### Expected behavior

I would like/expect the override parameter to be directly applied when calling the class constructor, so the instance knows its target state during `__init__` and doesn't fail the Tesseract install check.

I'm looking at updating [this script bundle](https://github.com/aws-samples/amazon-textract-transformer-pipeline/tree/main/notebooks/src) in the [aws-samples/amazon-textract-transformer-pipeline](https://github.com/aws-samples/amazon-textract-transformer-pipeline) sample (which currently uses LLMv1) - and would like to continue using Auto classes if possible to make switching between similar models (LLMv1, v2, XLM) relatively straightforward. However, in this context we're using external OCR from Amazon Textract and hoping not to bloat the container image with an unnecessary Tesseract install.
