fix the get_size_with_aspect_ratio in max_size situation
Author: SangbumChoi
Pull request: yes

# What does this PR do?

This fix the issue as the following example. AKA round issue.
This is important when the size should be divisible by specific value such as 32, 16.
@amyeroberts 

```
from transformers import DetrImageProcessor
from PIL import Image
import requests
import torch
import io
import numpy as np


def rgb_to_id(color):
    if isinstance(color, np.ndarray) and len(color.shape) == 3:
        if color.dtype == np.uint8:
            color = color.astype(np.int32)
        return color[:, :, 0] + 256 * color[:, :, 1] + 256 * 256 * color[:, :, 2]
    return int(color[0] + 256 * color[1] + 256 * 256 * color[2])
    
height, width = 653, 958
image = Image.new('RGB', (width, height), 'white')
image_processor = DetrImageProcessor.from_pretrained('facebook/detr-resnet-50')
image_processor.size = \
{
    "longest_edge": 640,
    "shortest_edge": 640
}
```

Before commit
```
# prepare inputs for the model
inputs = image_processor(images=image, return_tensors="pt")
print(inputs['pixel_values'].shape)
torch.Size([1, 3, 436, 639])
```

After commit
```
# prepare inputs for the model
inputs = image_processor(images=image, return_tensors="pt")
print(inputs['pixel_values'].shape)
torch.Size([1, 3, 436, 640])
```

<!--
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.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [X] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [X] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [X] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- 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 and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

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: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Additional script
```
height, width = 653, 958

for i in range(640,660):
    image = Image.new('RGB', (width, i), 'white')
    
    print(image.size)
    
    image_processor = DetrImageProcessor.from_pretrained('facebook/detr-resnet-50')
    image_processor.size = \
    {
        "longest_edge": 640,
        "shortest_edge": 640
    }
    
    # prepare inputs for the model
    inputs = image_processor(images=image, return_tensors="pt")
    print(inputs['pixel_values'].shape)
```

```
(958, 640)
torch.Size([1, 3, 428, 640])
...
(958, 659)
torch.Size([1, 3, 440, 640])
```

https://github.com/huggingface/transformers/blob/fce78fd0e917312da36cea4d352896a8f6ec9cdc/src/transformers/models/yolos/image_processing_yolos.py#L104

We can consider merging both all-in-one

  @SangbumChoi Thanks for fixing, a great catch!
  
  > We can consider merging both all-in-one
  
will be great to have them consistent, but take into consideration that yolos function "round" height and width to the lowest divisible value

I will update the yolos and the test function and ping again.

@qubvel @amyeroberts I added the screenshot which fails at the main branch and success in here.

For the record, I tried to make yolos consistent to all the other function. However, it turns out it needs to remove `#Copied from line` which I would like to maintain. As a result I just changed it with appropriate format.

I just added test on the detr but if it seems good I could add it to all the related models.

<img width="1194" alt="Screenshot 2024-05-23 at 10 18 59 PM" src="https://github.com/huggingface/transformers/assets/34004152/8dadd196-da2a-481f-8ca6-591826c03eb7">


I have added the 3 more cases which is total 5 cases. Note that max_size should be always set in the situation of get_size_with_aspect_ratio! Again I just added test on the detr but if it seems good I could add it to all the related models :)

@amyeroberts Hi amy, since recent merge has deprecated DETA. I also removed in here.

@amyeroberts Could you rerun the CI?

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