EoMT: `post_process_semantic_segmentation` fails if `patch_offsets` is None
Author: simonreise
Pull request: no
Labels: name: bug

### System Info

transformers 4.57.3
python 3.13.9

### Who can help?

@yonigozlan @molbap

### Information

- [x] 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

If we will try to process the square images (e.g. 400x400) with EoMT, the `post_process_semantic_segmentation` function will fail, because `merge_image_patches` function expects that `patch_offsets` parameter is set, and it is not.

Let's modify the example EoMT script to process the square image: 

```py
import matplotlib.pyplot as plt
import requests
import torch
from PIL import Image

from transformers import EomtForUniversalSegmentation, EomtImageProcessorFast, EomtConfig

# Crop the original image to a square
image = Image.open(requests.get("http://images.cocodataset.org/val2017/000000039769.jpg", stream=True).raw).crop((0, 0, 400, 400))

# Setting up the processor without do_split image, because our image is already a square
processor = processor = EomtImageProcessorFast(
    do_split_image=False,
)
config = EomtConfig()
model = EomtForUniversalSegmentation(config)

inputs = processor(
    images=image,
    return_tensors="pt",
)
print("patch_offsets" in inputs)

with torch.inference_mode():
    outputs = model(**inputs)

print(outputs.patch_offsets)

# Prepare the original image size in the format (height, width)
target_sizes = [(image.height, image.width)]

# Post-process the model outputs to get final segmentation prediction
preds = processor.post_process_semantic_segmentation(
    outputs,
    target_sizes=target_sizes,
)
```

The print outputs will be:

```
False
None
```
which means that inputs, generated by image processor do not contain `patch_offsets` parameter, and `patch_offsets` of the model outputs is None.

Then we will get an error:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[19], line 31
     28 target_sizes = [(image.height, image.width)]
     30 # Post-process the model outputs to get final segmentation prediction
---> 31 preds = processor.post_process_semantic_segmentation(
     32     outputs,
     33     target_sizes=target_sizes,
     34 )

File [~\Documents\geo\.pixi\envs\default\Lib\site-packages\transformers\models\eomt\image_processing_eomt_fast.py:407](http://localhost:8888/lab/workspaces/auto-B/tree/rsp-test/~/Documents/geo/.pixi/envs/default/Lib/site-packages/transformers/models/eomt/image_processing_eomt_fast.py#line=406), in EomtImageProcessorFast.post_process_semantic_segmentation(self, outputs, target_sizes, size)
    403 masks_probs = masks_queries_logits.sigmoid()  # [batch_size, num_queries, height, width]
    405 segmentation_logits = torch.einsum("bqc, bqhw -> bchw", masks_classes, masks_probs)
--> 407 output_logits = self.merge_image_patches(segmentation_logits, patch_offsets, target_sizes, size)
    409 preds = [logit.argmax(dim=0) for logit in output_logits]
    410 return preds

File [~\Documents\geo\.pixi\envs\default\Lib\site-packages\transformers\models\eomt\image_processing_eomt_fast.py:336](http://localhost:8888/lab/workspaces/auto-B/tree/rsp-test/~/Documents/geo/.pixi/envs/default/Lib/site-packages/transformers/models/eomt/image_processing_eomt_fast.py#line=335), in EomtImageProcessorFast.merge_image_patches(self, segmentation_logits, patch_offsets, target_sizes, size)
    333     patch_counts.append(torch.zeros((num_classes, height, width), device=segmentation_logits.device))
    335 # Stitch patches back into full-sized logit maps
--> 336 for patch_idx, (image_idx, patch_start, patch_end) in enumerate(patch_offsets):
    337     if target_sizes[image_idx][0] > target_sizes[image_idx][1]:
    338         aggregated_logits[image_idx][:, patch_start:patch_end, :] += segmentation_logits[patch_idx]

TypeError: 'NoneType' object is not iterable
```

`merge_image_patches` tries to restore the original images by merging the patches, but since our image was not split into patches, and no `patch_offsets` were generated, it fails.

### Expected behavior

Probably, if we do not need to merge the image patches, we can just use the code that is used in other image processors to avoid this error, since in this case image post processing is the same as for other models

Comments: