



import functools
import math

import flax.linen as nn
import jax
import jax.numpy as jnp
def 	lowercase_							(A			:			str		, A			:			str		, A			:			Any		, A			:			Optional[Any]		, A			:			int = 4_0_9_6				):
       snake_case__     ,    snake_case__     ,    snake_case__							:     str            =     key.shape[-3:]
       snake_case__							:     Dict            =     value.shape[-1]
       snake_case__							:     int            =     min(A		, A				)
       snake_case__							:     List[Any]            =     query / jnp.sqrt(A				)

       @functools.partial(jax.checkpoint		, prevent_cse=A				)
       def summarize_chunk(A			:			Union[str, Any]		, A			:			Any		, A			:			Tuple				):
              snake_case__							:     int            =     jnp.einsum('...qhd,...khd->...qhk'		, A		, A		, precision=A				)

              snake_case__							:     int            =     jnp.max(A		, axis=-1		, keepdims=A				)
              snake_case__							:     Optional[int]            =     jax.lax.stop_gradient(A				)
              snake_case__							:     Tuple            =     jnp.exp(attn_weights - max_score				)

              snake_case__							:     Tuple            =     jnp.einsum('...vhf,...qhv->...qhf'		, A		, A		, precision=A				)
              snake_case__							:     str            =     jnp.einsum('...qhk->...qh'		, A				)

              return (exp_values, exp_weights.sum(axis=-1				), max_score)

       def chunk_scanner(A			:			Any				):
              # julienne key array
              snake_case__							:     Union[str, Any]            =     jax.lax.dynamic_slice(
                  operand=A		, start_indices=[0] * (key.ndim - 3) + [chunk_idx, 0, 0]		, slice_sizes=list(key.shape[:-3]				) + [key_chunk_size, num_heads, k_features]		, )

              # julienne value array
              snake_case__							:     Optional[int]            =     jax.lax.dynamic_slice(
                  operand=A		, start_indices=[0] * (value.ndim - 3) + [chunk_idx, 0, 0]		, slice_sizes=list(value.shape[:-3]				) + [key_chunk_size, num_heads, v_features]		, )

              return summarize_chunk(A		, A		, A				)

       snake_case__     ,    snake_case__     ,    snake_case__							:     Optional[Any]            =     jax.lax.map(f=A		, xs=jnp.arange(0		, A		, A				)				)

       snake_case__							:     List[str]            =     jnp.max(A		, axis=0		, keepdims=A				)
       snake_case__							:     List[str]            =     jnp.exp(chunk_max - global_max				)

       chunk_values *= jnp.expand_dims(A		, axis=-1				)
       chunk_weights *= max_diffs

       snake_case__							:     Dict            =     chunk_values.sum(axis=0				)
       snake_case__							:     Union[str, Any]            =     jnp.expand_dims(A		, -1				).sum(axis=0				)

       return all_values / all_weights
def 	lowercase_							(A			:			List[Any]		, A			:			Optional[int]		, A			:			List[Any]		, A			:			Union[str, Any]=jax.lax.Precision.HIGHEST		, A			:			int = 1_0_2_4		, A			:			int = 4_0_9_6				):
       snake_case__     ,    snake_case__     ,    snake_case__							:     List[Any]            =     query.shape[-3:]

       def chunk_scanner(A			:			Optional[Any]		, A			:			Any				):
              # julienne query array
              snake_case__							:     Tuple            =     jax.lax.dynamic_slice(
                  operand=A		, start_indices=([0] * (query.ndim - 3)) + [chunk_idx, 0, 0]		, slice_sizes=list(query.shape[:-3]				) + [min(A		, A				), num_heads, q_features]		, )

              return (
                  chunk_idx + query_chunk_size,  # unused ignore it
                  _query_chunk_attention(
                      query=A		, key=A		, value=A		, precision=A		, key_chunk_size=A				),
              )

       snake_case__     ,    snake_case__							:     List[Any]            =     jax.lax.scan(
           f=A		, init=0		, xs=A		, length=math.ceil(num_q / query_chunk_size				)				)

       return jnp.concatenate(A		, axis=-3				)  # fuse the chunked result back




class  snake_case__						(	nn.Module					):






     """simple docstring"""


     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     8
     _SCREAMING_SNAKE_CASE            =     64
     _SCREAMING_SNAKE_CASE            =     0.0
     _SCREAMING_SNAKE_CASE            =     False
     _SCREAMING_SNAKE_CASE            =     jnp.floataa






     def        lowercase_       (	self  :  Union[str, Any] )       ->Any:
            snake_case__							:     Optional[Any]            =     self.dim_head * self.heads
            snake_case__							:     List[Any]            =     self.dim_head**-0.5

            # Weights were exported with old names {to_q, to_k, to_v, to_out}
            snake_case__							:     Dict            =     nn.Dense(_snake_case,			use_bias=_snake_case,			dtype=self.dtype,			name='to_q' )
            snake_case__							:     List[str]            =     nn.Dense(_snake_case,			use_bias=_snake_case,			dtype=self.dtype,			name='to_k' )
            snake_case__							:     str            =     nn.Dense(_snake_case,			use_bias=_snake_case,			dtype=self.dtype,			name='to_v' )

            snake_case__							:     List[str]            =     nn.Dense(self.query_dim,			dtype=self.dtype,			name='to_out_0' )
            snake_case__							:     str            =     nn.Dropout(rate=self.dropout )






     def        lowercase_       (	self  :  List[Any],			_snake_case  :  Union[str, Any] )       ->Dict:
            snake_case__     ,    snake_case__     ,    snake_case__							:     List[Any]            =     tensor.shape
            snake_case__							:     Tuple            =     self.heads
            snake_case__							:     int            =     tensor.reshape(_snake_case,			_snake_case,			_snake_case,			dim // head_size )
            snake_case__							:     Tuple            =     jnp.transpose(_snake_case,			(0, 2, 1, 3) )
            snake_case__							:     List[str]            =     tensor.reshape(batch_size * head_size,			_snake_case,			dim // head_size )
            return tensor






     def        lowercase_       (	self  :  List[Any],			_snake_case  :  Union[str, Any] )       ->Optional[Any]:
            snake_case__     ,    snake_case__     ,    snake_case__							:     Dict            =     tensor.shape
            snake_case__							:     List[Any]            =     self.heads
            snake_case__							:     Optional[Any]            =     tensor.reshape(batch_size // head_size,			_snake_case,			_snake_case,			_snake_case )
            snake_case__							:     Tuple            =     jnp.transpose(_snake_case,			(0, 2, 1, 3) )
            snake_case__							:     List[Any]            =     tensor.reshape(batch_size // head_size,			_snake_case,			dim * head_size )
            return tensor






     def __call__(	self  :  Tuple,			_snake_case  :  int,			_snake_case  :  List[Any]=None,			_snake_case  :  List[Any]=True )       ->Optional[Any]:
            snake_case__							:     Any            =     hidden_states if context is None else context

            snake_case__							:     Optional[Any]            =     self.query(_snake_case )
            snake_case__							:     Tuple            =     self.key(_snake_case )
            snake_case__							:     Optional[Any]            =     self.value(_snake_case )

            snake_case__							:     List[str]            =     self.reshape_heads_to_batch_dim(_snake_case )
            snake_case__							:     Any            =     self.reshape_heads_to_batch_dim(_snake_case )
            snake_case__							:     str            =     self.reshape_heads_to_batch_dim(_snake_case )

            if self.use_memory_efficient_attention:
                   snake_case__							:     Optional[Any]            =     query_states.transpose(1,			0,			2 )
                   snake_case__							:     str            =     key_states.transpose(1,			0,			2 )
                   snake_case__							:     List[Any]            =     value_states.transpose(1,			0,			2 )

                   # this if statement create a chunk size for each layer of the unet
                   # the chunk size is equal to the query_length dimension of the deepest layer of the unet

                   snake_case__							:     Optional[Any]            =     query_states.shape[-3]
                   if flatten_latent_dim % 6_4 == 0:
                          snake_case__							:     List[Any]            =     int(flatten_latent_dim / 6_4 )
                   elif flatten_latent_dim % 1_6 == 0:
                          snake_case__							:     List[str]            =     int(flatten_latent_dim / 1_6 )
                   elif flatten_latent_dim % 4 == 0:
                          snake_case__							:     Optional[Any]            =     int(flatten_latent_dim / 4 )
                   else:
                          snake_case__							:     Dict            =     int(_snake_case )

                   snake_case__							:     Union[str, Any]            =     jax_memory_efficient_attention(
                       _snake_case,			_snake_case,			_snake_case,			query_chunk_size=_snake_case,			key_chunk_size=4_0_9_6 * 4 )

                   snake_case__							:     int            =     hidden_states.transpose(1,			0,			2 )
            else:
                   # compute attentions
                   snake_case__							:     List[Any]            =     jnp.einsum('b i d, b j d->b i j',			_snake_case,			_snake_case )
                   snake_case__							:     Tuple            =     attention_scores * self.scale
                   snake_case__							:     Optional[Any]            =     nn.softmax(_snake_case,			axis=2 )

                   # attend to values
                   snake_case__							:     Optional[int]            =     jnp.einsum('b i j, b j d -> b i d',			_snake_case,			_snake_case )

            snake_case__							:     List[Any]            =     self.reshape_batch_dim_to_heads(_snake_case )
            snake_case__							:     Optional[int]            =     self.proj_attn(_snake_case )
            return self.dropout_layer(_snake_case,			deterministic=_snake_case )




class  snake_case__						(	nn.Module					):






     """simple docstring"""


     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     0.0
     _SCREAMING_SNAKE_CASE            =     False
     _SCREAMING_SNAKE_CASE            =     jnp.floataa
     _SCREAMING_SNAKE_CASE            =     False






     def        lowercase_       (	self  :  Tuple )       ->Tuple:
            # self attention (or cross_attention if only_cross_attention is True)
            snake_case__							:     List[str]            =     FlaxAttention(
                self.dim,			self.n_heads,			self.d_head,			self.dropout,			self.use_memory_efficient_attention,			dtype=self.dtype )
            # cross attention
            snake_case__							:     str            =     FlaxAttention(
                self.dim,			self.n_heads,			self.d_head,			self.dropout,			self.use_memory_efficient_attention,			dtype=self.dtype )
            snake_case__							:     Dict            =     FlaxFeedForward(dim=self.dim,			dropout=self.dropout,			dtype=self.dtype )
            snake_case__							:     Optional[Any]            =     nn.LayerNorm(epsilon=1e-5,			dtype=self.dtype )
            snake_case__							:     int            =     nn.LayerNorm(epsilon=1e-5,			dtype=self.dtype )
            snake_case__							:     Tuple            =     nn.LayerNorm(epsilon=1e-5,			dtype=self.dtype )
            snake_case__							:     str            =     nn.Dropout(rate=self.dropout )






     def __call__(	self  :  Union[str, Any],			_snake_case  :  Union[str, Any],			_snake_case  :  List[Any],			_snake_case  :  Optional[Any]=True )       ->str:
            # self attention
            snake_case__							:     List[Any]            =     hidden_states
            if self.only_cross_attention:
                   snake_case__							:     Optional[Any]            =     self.attna(self.norma(_snake_case ),			_snake_case,			deterministic=_snake_case )
            else:
                   snake_case__							:     List[Any]            =     self.attna(self.norma(_snake_case ),			deterministic=_snake_case )
            snake_case__							:     Optional[Any]            =     hidden_states + residual

            # cross attention
            snake_case__							:     str            =     hidden_states
            snake_case__							:     int            =     self.attna(self.norma(_snake_case ),			_snake_case,			deterministic=_snake_case )
            snake_case__							:     Any            =     hidden_states + residual

            # feed forward
            snake_case__							:     Union[str, Any]            =     hidden_states
            snake_case__							:     Optional[int]            =     self.ff(self.norma(_snake_case ),			deterministic=_snake_case )
            snake_case__							:     int            =     hidden_states + residual

            return self.dropout_layer(_snake_case,			deterministic=_snake_case )




class  snake_case__						(	nn.Module					):






     """simple docstring"""


     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     1
     _SCREAMING_SNAKE_CASE            =     0.0
     _SCREAMING_SNAKE_CASE            =     False
     _SCREAMING_SNAKE_CASE            =     False
     _SCREAMING_SNAKE_CASE            =     jnp.floataa
     _SCREAMING_SNAKE_CASE            =     False






     def        lowercase_       (	self  :  Optional[Any] )       ->List[str]:
            snake_case__							:     List[Any]            =     nn.GroupNorm(num_groups=3_2,			epsilon=1e-5 )

            snake_case__							:     Optional[Any]            =     self.n_heads * self.d_head
            if self.use_linear_projection:
                   snake_case__							:     Optional[int]            =     nn.Dense(_snake_case,			dtype=self.dtype )
            else:
                   snake_case__							:     int            =     nn.Conv(
                       _snake_case,			kernel_size=(1, 1),			strides=(1, 1),			padding='VALID',			dtype=self.dtype,			)

            snake_case__							:     Dict            =     [
                FlaxBasicTransformerBlock(
                    _snake_case,			self.n_heads,			self.d_head,			dropout=self.dropout,			only_cross_attention=self.only_cross_attention,			dtype=self.dtype,			use_memory_efficient_attention=self.use_memory_efficient_attention,			)
                for _ in range(self.depth )
            ]

            if self.use_linear_projection:
                   snake_case__							:     Dict            =     nn.Dense(_snake_case,			dtype=self.dtype )
            else:
                   snake_case__							:     Optional[Any]            =     nn.Conv(
                       _snake_case,			kernel_size=(1, 1),			strides=(1, 1),			padding='VALID',			dtype=self.dtype,			)

            snake_case__							:     Optional[Any]            =     nn.Dropout(rate=self.dropout )






     def __call__(	self  :  Optional[Any],			_snake_case  :  Dict,			_snake_case  :  str,			_snake_case  :  Dict=True )       ->Any:
            snake_case__     ,    snake_case__     ,    snake_case__     ,    snake_case__							:     List[Any]            =     hidden_states.shape
            snake_case__							:     Union[str, Any]            =     hidden_states
            snake_case__							:     int            =     self.norm(_snake_case )
            if self.use_linear_projection:
                   snake_case__							:     Optional[int]            =     hidden_states.reshape(_snake_case,			height * width,			_snake_case )
                   snake_case__							:     Any            =     self.proj_in(_snake_case )
            else:
                   snake_case__							:     Union[str, Any]            =     self.proj_in(_snake_case )
                   snake_case__							:     str            =     hidden_states.reshape(_snake_case,			height * width,			_snake_case )

            for transformer_block in self.transformer_blocks:
                   snake_case__							:     Optional[int]            =     transformer_block(_snake_case,			_snake_case,			deterministic=_snake_case )

            if self.use_linear_projection:
                   snake_case__							:     Dict            =     self.proj_out(_snake_case )
                   snake_case__							:     Union[str, Any]            =     hidden_states.reshape(_snake_case,			_snake_case,			_snake_case,			_snake_case )
            else:
                   snake_case__							:     List[Any]            =     hidden_states.reshape(_snake_case,			_snake_case,			_snake_case,			_snake_case )
                   snake_case__							:     Optional[Any]            =     self.proj_out(_snake_case )

            snake_case__							:     Any            =     hidden_states + residual
            return self.dropout_layer(_snake_case,			deterministic=_snake_case )




class  snake_case__						(	nn.Module					):






     """simple docstring"""


     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     0.0
     _SCREAMING_SNAKE_CASE            =     jnp.floataa






     def        lowercase_       (	self  :  Any )       ->Any:
            # The second linear layer needs to be called
            # net_2 for now to match the index of the Sequential layer
            snake_case__							:     int            =     FlaxGEGLU(self.dim,			self.dropout,			self.dtype )
            snake_case__							:     Tuple            =     nn.Dense(self.dim,			dtype=self.dtype )






     def __call__(	self  :  List[Any],			_snake_case  :  List[Any],			_snake_case  :  str=True )       ->str:
            snake_case__							:     Optional[int]            =     self.net_a(_snake_case,			deterministic=_snake_case )
            snake_case__							:     Optional[Any]            =     self.net_a(_snake_case )
            return hidden_states




class  snake_case__						(	nn.Module					):






     """simple docstring"""


     _SCREAMING_SNAKE_CASE            =     42
     _SCREAMING_SNAKE_CASE            =     0.0
     _SCREAMING_SNAKE_CASE            =     jnp.floataa






     def        lowercase_       (	self  :  Tuple )       ->List[Any]:
            snake_case__							:     List[str]            =     self.dim * 4
            snake_case__							:     str            =     nn.Dense(inner_dim * 2,			dtype=self.dtype )
            snake_case__							:     str            =     nn.Dropout(rate=self.dropout )






     def __call__(	self  :  Union[str, Any],			_snake_case  :  Union[str, Any],			_snake_case  :  Dict=True )       ->Optional[Any]:
            snake_case__							:     int            =     self.proj(_snake_case )
            snake_case__     ,    snake_case__							:     int            =     jnp.split(_snake_case,			2,			axis=2 )
            return self.dropout_layer(hidden_linear * nn.gelu(_snake_case ),			deterministic=_snake_case )











import shutil
import tempfile
import unittest

import pytest

from transformers import WhisperTokenizer, is_speech_available
from transformers.testing_utils import require_sentencepiece, require_torch, require_torchaudio

from .test_feature_extraction_whisper import floats_list


if is_speech_available():
 from transformers import WhisperFeatureExtractor, WhisperProcessor


a_       :List[Any]				  =				50_358
a_       :int				  =				50_362




@require_torch
@require_torchaudio
@require_sentencepiece
class  snake_case__						(	unittest.TestCase					):






     """simple docstring"""


     def        lowercase_       (	self  :  Dict )       ->List[Any]:
            snake_case__							:     int            =     'openai/whisper-small.en'
            snake_case__							:     List[Any]            =     tempfile.mkdtemp()






     def        lowercase_       (	self  :  Any,			**_snake_case  :  List[str] )       ->Union[str, Any]:
            return WhisperTokenizer.from_pretrained(self.checkpoint,			**_snake_case )






     def        lowercase_       (	self  :  Union[str, Any],			**_snake_case  :  int )       ->Optional[int]:
            return WhisperFeatureExtractor.from_pretrained(self.checkpoint,			**_snake_case )






     def        lowercase_       (	self  :  Any )       ->Union[str, Any]:
            shutil.rmtree(self.tmpdirname )






     def        lowercase_       (	self  :  Dict )       ->Tuple:
            snake_case__							:     Dict            =     self.get_tokenizer()
            snake_case__							:     List[str]            =     self.get_feature_extractor()

            snake_case__							:     List[Any]            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )

            processor.save_pretrained(self.tmpdirname )
            snake_case__							:     Dict            =     WhisperProcessor.from_pretrained(self.tmpdirname )

            self.assertEqual(processor.tokenizer.get_vocab(),			tokenizer.get_vocab() )
            self.assertIsInstance(processor.tokenizer,			_snake_case )

            self.assertEqual(processor.feature_extractor.to_json_string(),			feature_extractor.to_json_string() )
            self.assertIsInstance(processor.feature_extractor,			_snake_case )






     def        lowercase_       (	self  :  List[Any] )       ->str:
            snake_case__							:     str            =     WhisperProcessor(tokenizer=self.get_tokenizer(),			feature_extractor=self.get_feature_extractor() )
            processor.save_pretrained(self.tmpdirname )

            snake_case__							:     Dict            =     self.get_tokenizer(bos_token='(BOS)',			eos_token='(EOS)' )
            snake_case__							:     List[str]            =     self.get_feature_extractor(do_normalize=_snake_case,			padding_value=1.0 )

            snake_case__							:     List[Any]            =     WhisperProcessor.from_pretrained(
                self.tmpdirname,			bos_token='(BOS)',			eos_token='(EOS)',			do_normalize=_snake_case,			padding_value=1.0 )

            self.assertEqual(processor.tokenizer.get_vocab(),			tokenizer_add_kwargs.get_vocab() )
            self.assertIsInstance(processor.tokenizer,			_snake_case )

            self.assertEqual(processor.feature_extractor.to_json_string(),			feature_extractor_add_kwargs.to_json_string() )
            self.assertIsInstance(processor.feature_extractor,			_snake_case )






     def        lowercase_       (	self  :  Union[str, Any] )       ->Dict:
            snake_case__							:     Dict            =     self.get_feature_extractor()
            snake_case__							:     Dict            =     self.get_tokenizer()

            snake_case__							:     List[Any]            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )

            snake_case__							:     int            =     floats_list((3, 1_0_0_0) )

            snake_case__							:     Optional[int]            =     feature_extractor(_snake_case,			return_tensors='np' )
            snake_case__							:     Optional[int]            =     processor(_snake_case,			return_tensors='np' )

            for key in input_feat_extract.keys():
                   self.assertAlmostEqual(input_feat_extract[key].sum(),			input_processor[key].sum(),			delta=1e-2 )






     def        lowercase_       (	self  :  Dict )       ->Any:
            snake_case__							:     Tuple            =     self.get_feature_extractor()
            snake_case__							:     Optional[int]            =     self.get_tokenizer()

            snake_case__							:     Optional[int]            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )

            snake_case__							:     Any            =     'This is a test string'

            snake_case__							:     Dict            =     processor(text=_snake_case )

            snake_case__							:     List[str]            =     tokenizer(_snake_case )

            for key in encoded_tok.keys():
                   self.assertListEqual(encoded_tok[key],			encoded_processor[key] )






     def        lowercase_       (	self  :  Dict )       ->Dict:
            snake_case__							:     Optional[Any]            =     self.get_feature_extractor()
            snake_case__							:     Optional[int]            =     self.get_tokenizer()

            snake_case__							:     Optional[int]            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )

            snake_case__							:     Union[str, Any]            =     [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

            snake_case__							:     List[str]            =     processor.batch_decode(_snake_case )
            snake_case__							:     Dict            =     tokenizer.batch_decode(_snake_case )

            self.assertListEqual(_snake_case,			_snake_case )






     def        lowercase_       (	self  :  Union[str, Any] )       ->Optional[Any]:
            snake_case__							:     str            =     self.get_feature_extractor()
            snake_case__							:     Dict            =     self.get_tokenizer()

            snake_case__							:     Any            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )

            self.assertListEqual(
                processor.model_input_names,			feature_extractor.model_input_names,			msg='`processor` and `feature_extractor` model input names do not match',			)






     def        lowercase_       (	self  :  int )       ->Dict:
            snake_case__							:     Tuple            =     self.get_feature_extractor()
            snake_case__							:     Tuple            =     self.get_tokenizer()

            snake_case__							:     Optional[int]            =     WhisperProcessor(tokenizer=_snake_case,			feature_extractor=_snake_case )
            snake_case__							:     Any            =     processor.get_decoder_prompt_ids(task='transcribe',			no_timestamps=_snake_case )

            self.assertIsInstance(_snake_case,			_snake_case )
            for ids in forced_decoder_ids:
                   self.assertIsInstance(_snake_case,			(list, tuple) )

            snake_case__							:     List[str]            =     [TRANSCRIBE, NOTIMESTAMPS]
            self.assertListEqual([ids[-1] for ids in forced_decoder_ids],			_snake_case )






     def        lowercase_       (	self  :  Optional[int] )       ->int:
            snake_case__							:     List[Any]            =     WhisperProcessor(tokenizer=self.get_tokenizer(),			feature_extractor=self.get_feature_extractor() )
            snake_case__							:     Optional[Any]            =     processor.get_prompt_ids('Mr. Quilter' )
            snake_case__							:     List[Any]            =     processor.tokenizer.decode(_snake_case )

            self.assertListEqual(prompt_ids.tolist(),			[5_0_3_6_0, 1_7_7_0, 1_3, 2_2_6_4, 3_4_6, 3_5_3] )
            self.assertEqual(_snake_case,			'<|startofprev|> Mr. Quilter' )






     def        lowercase_       (	self  :  Tuple )       ->Tuple:
            snake_case__							:     int            =     WhisperProcessor(tokenizer=self.get_tokenizer(),			feature_extractor=self.get_feature_extractor() )
            snake_case__							:     List[str]            =     processor.get_prompt_ids('' )
            snake_case__							:     List[Any]            =     processor.tokenizer.decode(_snake_case )

            self.assertListEqual(prompt_ids.tolist(),			[5_0_3_6_0, 2_2_0] )
            self.assertEqual(_snake_case,			'<|startofprev|> ' )






     def        lowercase_       (	self  :  Tuple )       ->str:
            snake_case__							:     Any            =     WhisperProcessor(tokenizer=self.get_tokenizer(),			feature_extractor=self.get_feature_extractor() )

            def _test_prompt_error_raised_helper(_snake_case  :  str,			_snake_case  :  int ):
                   with pytest.raises(_snake_case ) as excinfo:
                          processor.get_prompt_ids(_snake_case )
                   snake_case__							:     Dict            =     F'''Encountered text in the prompt corresponding to disallowed special token: {special_token}.'''
                   self.assertEqual(_snake_case,			str(excinfo.value ) )

            _test_prompt_error_raised_helper('<|startofprev|> test',			'<|startofprev|>' )
            _test_prompt_error_raised_helper('test <|notimestamps|>',			'<|notimestamps|>' )
            _test_prompt_error_raised_helper('test <|zh|> test <|transcribe|>',			'<|zh|>' )






