




"""simple docstring"""




from ...processing_utils import ProcessorMixin






class 					__magic_name__							( UpperCAmelCase__       ):






				'''simple docstring'''
				__UpperCamelCase    						=		"WhisperFeatureExtractor"
				__UpperCamelCase    						=		"WhisperTokenizer"





				def __init__( self	,				_a	,				_a				):





							"""simple docstring"""
							super().__init__(_a	,				_a				)
							lowerCamelCase       =      self.feature_extractor
							lowerCamelCase       =      False





				def      _lowerCAmelCase       ( self	,				_a=None	,				_a=None	,				_a=True				):





							"""simple docstring"""
							return self.tokenizer.get_decoder_prompt_ids(task=_a	,				language=_a	,				no_timestamps=_a				)





				def __call__( self	,				*_a	,				**_a				):





							"""simple docstring"""
							# For backward compatibility
							if self._in_target_context_manager:
										return self.current_processor(*_a	,				**_a				)

							lowerCamelCase       =      kwargs.pop("""audio"""	,				_a				)
							lowerCamelCase       =      kwargs.pop("""sampling_rate"""	,				_a				)
							lowerCamelCase       =      kwargs.pop("""text"""	,				_a				)
							if len(_a				) > 0:
										lowerCamelCase       =      args[0]
										lowerCamelCase       =      args[1:]

							if audio is None and text is None:
										raise ValueError("""You need to specify either an `audio` or `text` input to process."""				)

							if audio is not None:
										lowerCamelCase       =      self.feature_extractor(_a	,				*_a	,				sampling_rate=_a	,				**_a				)
							if text is not None:
										lowerCamelCase       =      self.tokenizer(_a	,				**_a				)

							if text is None:
										return inputs

							elif audio is None:
										return encodings
							else:
										lowerCamelCase       =      encodings["""input_ids"""]
										return inputs





				def      _lowerCAmelCase       ( self	,				*_a	,				**_a				):





							"""simple docstring"""
							return self.tokenizer.batch_decode(*_a	,				**_a				)





				def      _lowerCAmelCase       ( self	,				*_a	,				**_a				):





							"""simple docstring"""
							return self.tokenizer.decode(*_a	,				**_a				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a="np"				):





							"""simple docstring"""
							return self.tokenizer.get_prompt_ids(_a	,				return_tensors=_a				)









"""simple docstring"""




import tempfile
import unittest

from make_student import create_student_by_copying_alternating_layers

from transformers import AutoConfig
from transformers.file_utils import cached_property
from transformers.testing_utils import require_torch


lowerCAmelCase							:    Optional[Any]  							=							"""sshleifer/bart-tiny-random"""
lowerCAmelCase							:    List[Any]  							=							"""patrickvonplaten/t5-tiny-random"""






@require_torch
class 					__magic_name__							( unittest.TestCase       ):






				'''simple docstring'''





				@cached_property
				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return AutoConfig.from_pretrained(_a				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     *lowerCamelCase       =      create_student_by_copying_alternating_layers(_a	,				tempfile.mkdtemp()	,				e=1	,				d=1				)
							self.assertEqual(student.config.num_hidden_layers	,				1				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     *lowerCamelCase       =      create_student_by_copying_alternating_layers(_a	,				tempfile.mkdtemp()	,				e=1	,				d=_a				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     *lowerCamelCase       =      create_student_by_copying_alternating_layers(_a	,				tempfile.mkdtemp()	,				e=1	,				d=_a				)
							self.assertEqual(student.config.encoder_layers	,				1				)
							self.assertEqual(student.config.decoder_layers	,				self.teacher_config.encoder_layers				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase   ,     *lowerCamelCase       =      create_student_by_copying_alternating_layers(_a	,				tempfile.mkdtemp()	,				e=1	,				d=1				)
							self.assertEqual(student.config.encoder_layers	,				1				)
							self.assertEqual(student.config.decoder_layers	,				1				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							with self.assertRaises(_a				):
										create_student_by_copying_alternating_layers(_a	,				tempfile.mkdtemp()	,				e=_a	,				d=_a				)



