From 0e417f407864e70ff17b61e3ad36b080aefcc54e Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 4 Apr 2026 16:21:26 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20transformers=20compat=20=E2=80=94=20find?= =?UTF-8?q?=5Fpruneable=5Fheads=5Fand=5Findices=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some transformers builds removed these from pytorch_utils. Fall back to modeling_utils which exposes them in all known versions. Co-Authored-By: Claude Sonnet 4.6 --- selva_core/ext/synchformer/hf_src/modeling_ast.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selva_core/ext/synchformer/hf_src/modeling_ast.py b/selva_core/ext/synchformer/hf_src/modeling_ast.py index 09ecf22..3355bb7 100644 --- a/selva_core/ext/synchformer/hf_src/modeling_ast.py +++ b/selva_core/ext/synchformer/hf_src/modeling_ast.py @@ -28,7 +28,10 @@ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from transformers.activations import ACT2FN from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, SequenceClassifierOutput from transformers.modeling_utils import PreTrainedModel -from transformers.pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer +try: + from transformers.pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer +except ImportError: + from transformers.modeling_utils import find_pruneable_heads_and_indices, prune_linear_layer from transformers.models.audio_spectrogram_transformer.modeling_audio_spectrogram_transformer import ASTConfig from transformers.utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging