import torch from transformers import WhisperPreTrainedModel, WhisperConfig from transformers.models.whisper.modeling_whisper import WhisperEncoder class WhisperEncoderOnlyModel(WhisperPreTrainedModel): config_class = WhisperConfig def __init__(self, config): super().__init__(config) self.encoder = WhisperEncoder(config) self.post_init() def forward(self, input_features, **kwargs): return self.encoder(input_features, **kwargs)