Add Fast Segformer Processor
Author: capnmav77
Pull request: yes

# What does this PR do?
Linked: https://github.com/huggingface/transformers/issues/36978

Adding fast processor for Segformer.

CC: @yonigozlan
<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->


<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @eustlb
- graph models: @clefourrier

Library:

- flax: @gante and @Rocketknight1
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc @MekkCyber

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @Rocketknight1
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

> Hi @capnmav77 , Thanks for working on this! Looks like the `segmentation_maps` processing logic from the slow image processor is missing here. You can take a look at how it's being handled for `BeitImageProcessorFast` as it is very similar to Segformer image processor! Here is the PR `BeitImageProcessorFast` #37005

hey @yonigozlan  i've added the segmentation_maps processing logic from the slow image processor also i've taken references from the beitimageprocessorFast it really helped a lot , do let me know what to do next 

Hey @yonigozlan , i have modified the code accordingly but there's a issue i'm not able to figure out , one local test fails : 
```
FAILED tests/models/segformer/test_image_processing_segformer.py::SegformerImageProcessingTest::test_slow_fast_equivalence - AssertionError: False is not true
```
do you have a fix for this i'm not able to understand why this is happening , the dims of the fast processor are 1 , C , H , W , which shouldn't be the case compared to the slow processor which has 1, H , W , i presume the labels are messed up somewhere . Please do lemme know the fix for that and do suggest code changes . 

here's the log output of the labels : 
```
tensor([[[ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  3,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  2,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  3,  3,  3,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18, 18,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18, 18,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  1,  1,  0,  0,  0,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
          10, 10,  2,  2,  2, 18, 18, 18, 18, 18, 18, 18,  2],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 18, 18, 18, 18, 18, 18],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10,  7,  7,  7,  7,  7]]])
tensor([[[[ 86,  87,  86,  ...,  82,  81,  80],
          [ 89,  90,  90,  ...,  83,  82,  80],
          [ 90,  92,  93,  ...,  85,  84,  83],
          ...,
          [ 99, 100, 101,  ..., 105, 101,  99],
          [102, 107, 107,  ..., 110, 108, 104],
          [ 97,  97, 103,  ..., 121, 119, 117]],

         [[138, 138, 138,  ..., 132, 131, 131],
          [140, 141, 141,  ..., 133, 132, 131],
          [142, 143, 143,  ..., 135, 134, 132],
          ...,
          [109, 108, 108,  ..., 108, 103, 102],
          [107, 108, 105,  ..., 111, 108, 106],
          [102,  99, 102,  ..., 114, 114, 114]],

         [[191, 193, 194,  ..., 191, 189, 188],
          [194, 196, 197,  ..., 194, 191, 189],
          [196, 199, 200,  ..., 196, 193, 191],
          ...,
          [ 62,  63,  63,  ...,  66,  64,  63],
          [ 62,  66,  66,  ...,  71,  70,  71],
          [ 58,  58,  61,  ..., 100, 102, 102]]]])
          ```

Hi, @yonigozlan  , all the tests pass apart from the following : 
FAILED tests/models/segformer/test_image_processing_segformer.py::SegformerImageProcessingTest::test_slow_fast_equivalence - AssertionError: False is not true

the tensors from the fast processor does not match the tensor from the slow one ? i've been trying to crack this issue but i'm not getting to the root cause , i assume it's some mishap in the reduce_label function ? or something related to labelling can you suggest fixes ? 
```
slow: 
tensor([[[ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  3,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           3,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  3,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  2,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  3,  3,  3,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  3,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18, 18,  2,  2,  2,  2],
         [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18,  2,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2,  2, 18, 18,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 5,  5,  5,  5,  5,  5,  5,  1,  1,  0,  0,  0,  2,  2,  2,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
           2,  2,  2,  2,  2,  2, 18, 18, 18,  2,  2,  2,  2],
         [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
          10, 10,  2,  2,  2, 18, 18, 18, 18, 18, 18, 18,  2],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 18, 18, 18, 18, 18, 18],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
          10, 10, 10, 10, 10, 10, 10, 10,  7,  7,  7,  7,  7 ]]]) - here is the change
 Fast: 
tensor([[[[ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  3,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
            3,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,
            2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  3,  2,  2,
            2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  3,  2,  2,  2,
            2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  3,  3,  3,  3,  2,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  2,  2,  4,  4,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  2,  9,  9,  2,  2,  2,  2],
          [ 3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  3, 14,  8,  2,  2,  2,  2],
          [ 4,  4,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  4, 15,  9,  2,  2,  2,  2],
          [ 5,  5,  4,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  4, 16,  9,  2,  2,  2,  2],
          [ 5,  5,  5,  4,  5,  5,  4,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2,  5, 17, 10,  2,  2,  2,  2],
          [ 5,  5,  5,  5,  5,  5,  5,  3,  2,  2,  2,  2,  2,  2,  2,  2,  2,
            2,  2,  2,  2,  2,  2, 10, 18, 10,  2,  2,  2,  2],
          [ 4,  4,  4,  4,  4,  3,  4,  2,  1,  1,  1,  1,  1,  1,  2,  2,  2,
            2,  2,  2,  2,  2,  4, 14, 18, 10,  2,  2,  2,  2],
          [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
            2,  2,  2,  2,  2,  8, 18, 18, 12,  3,  2,  2,  2],
          [ 1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  3,  3,  3,  4,  5,
            6,  6,  5,  5,  4, 12, 18, 18, 17, 13, 11, 10,  4],
          [ 6,  7,  8,  8,  8,  8,  8,  9,  9,  8,  8,  9,  9,  9, 10, 10, 10,
           10, 10, 10, 10, 10, 11, 13, 14, 16, 17, 17, 17, 14],
          [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
           10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 12, 12],
          [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
           10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
          [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
           10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,  9,  9],
          [ 9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10,
           10, 10, 10, 10, 10, 10,  9,  9,  8,  7,  7,  7,  6 ]]]])
           
           ```

Hi @capnmav77 now that the #37005 is merged, you could take a look at the segmentation maps logic. I think that could be of use to you.

hey @yonigozlan , the image processing fast segformer batched works perfectly but the labels of a single image are not matched , this discrepancy is likely due to inherent differences in the NEAREST interpolation between PIL (used by the slow processor) and TorchVision (used by the fast processor), which can be very difficult to perfectly align. what do you suggest i do ? 

out of all the tests , The batched tests pass , but the test_slow_fast_equivalence for a single image which matches labels fails , we can modify the testcase to check for dtype and labels size which pass .

Hey @capnmav77 ! Sorry for the delay. Have you tried with NEAREST_EXACT? It could reduce the differences. If you still have issues we might just increase the tolerance for equivalence tests for this model 

Hey @yonigozlan , i've done the required changes and apparantly the maximum difference is 2 hence i've updated the tolerance value to 2.5 in the testcode and all the testcases pass . Let me know if i need to change anything else now ? 


Hi @capnmav77! You should probably implement the same fix as in #38042 , because as far as I can see your current code applies `reduce_labels` not only to the labels, but also to the images

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37024). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, beit, segformer