[Misc] Remove code paths for Transformers < 5.16.1 (#59762)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-10-02 11:17:24 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 8c60714da5
commit 5d20979fc9
18 changed files with 142 additions and 757 deletions
+2 -12
View File
@@ -61,10 +61,8 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
"""HF-compatible duck-typed ``fetch_audio``.
Mirrors :meth:`transformers.SequenceFeatureExtractor.fetch_audio` so
:class:`transformers.ProcessorMixin.prepare_inputs_layout` (added in
transformers 5.10) works on this duck-typed feature extractor. Older
transformers versions never invoke this method, so the addition is a
no-op there.
:class:`transformers.ProcessorMixin.prepare_inputs_layout` works on this
duck-typed feature extractor.
Accepts the same shapes as ``SequenceFeatureExtractor.fetch_audio``:
@@ -77,11 +75,6 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
``ProcessorMixin.prepare_inputs_layout`` always passes already-decoded
audio (numpy array or torch tensor), so the str / list-of-str branches
exist only to keep the contract identical to the upstream method.
The semantics of ``transformers.audio_utils.is_valid_audio`` differ
between transformers versions (5.9 only accepts ndarray/tensor; 5.10
also accepts ``list[float]``). We detect ``list[float]`` explicitly to
keep behavior identical across versions.
"""
from transformers.audio_utils import is_valid_audio
@@ -89,9 +82,6 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
if is_valid_audio(audio_url_or_urls):
return audio_url_or_urls
if isinstance(audio_url_or_urls, (list, tuple)):
if audio_url_or_urls and isinstance(audio_url_or_urls[0], float):
# A single audio represented as ``list[float]``.
return audio_url_or_urls
return [
self.fetch_audio(x, sampling_rate=sampling_rate)
for x in audio_url_or_urls