Fix IndexError in SequenceFeatureExtractor.pad on all-empty batch
Author: Osamaali313
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47389)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47389)
<!-- ci-dashboard-badge:end -->

# What does this PR do?

`SequenceFeatureExtractor.pad` (`src/transformers/feature_extraction_sequence_utils.py`) — the padding entry point for every audio feature extractor (Wav2Vec2, Whisper, CLAP, EnCodec, Gemma3n, … 30 subclasses) — crashes with `IndexError` when the whole batch is empty.

When the first element of the batch is an empty list/tuple, `pad` scans for the first non-empty element to infer the input type:

```python
first_element = required_input[0]
if isinstance(first_element, (list, tuple)):
    # first_element might be an empty list/tuple in some edge cases so we grab the first non empty element.
    index = 0
    while len(required_input[index]) == 0:   # unbounded
        index += 1
    if index < len(required_input):
        first_element = required_input[index][0]
```

The `while` loop has no upper bound, so if **every** element in the batch is empty it increments `index` past the end and raises `IndexError: list index out of range` — before the following `if index < len(required_input):` guard (which was clearly meant to handle exactly this case) can ever run.

## Evidence this is unintended

The analogous code in `PreTrainedTokenizerBase.pad` (`tokenization_utils_base.py`) does the same "grab the first non-empty element" with a **bounded** loop, and its comment explicitly notes that an all-empty batch should just be left alone:

```python
first_element = required_input[0]
if isinstance(first_element, (list, tuple)):
    # first_element might be an empty list/tuple in some edge cases so we grab the first non empty element.
    for item in required_input:
        if len(item) > 0:
            first_element = item[0]
            break
    # At this state, if `first_element` is still a list/tuple, it's an empty one so there is nothing to do.
```

## Fix

Bound the loop so the existing guard is reached and an all-empty batch is handled gracefully instead of crashing:

```python
while index < len(required_input) and len(required_input[index]) == 0:
    index += 1
```

## Reproduction

```python
from transformers import Wav2Vec2FeatureExtractor
from transformers.feature_extraction_utils import BatchFeature

fe = Wav2Vec2FeatureExtractor(feature_size=1, sampling_rate=16000, padding_value=0.0, return_attention_mask=False)
fe.pad(BatchFeature({"input_values": [[], []]}), padding="longest")
```

| | result |
|---|---|
| before | `IndexError: list index out of range` ❌ |
| after | returns a `BatchFeature` with 2 (empty) rows ✅ |

A regression test is added in `tests/utils/test_feature_extraction_utils.py`.

## Before submitting
- [x] This PR fixes a bug.
- [x] Added a regression test (`SequenceFeatureExtractorPadTester.test_pad_all_empty_batch_does_not_raise`).

Comments:
<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47389)
**Latest run:** [29606181675:2](https://github.com/huggingface/transformers/actions/runs/29606181675)
**Result:** `success` | **Jobs:** 15 | **Tests:** 169,057 | **Failures:** 0 | **Duration:** 14h 46m

<!-- ci-dashboard-recap:end -->