



"""simple docstring"""
import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import ConvNextConfig, ConvNextForImageClassification, ConvNextImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
_UpperCAmelCase       =     logging.get_logger(__name__)





def        __magic_name__			(							lowercase	):
   SCREAMING_SNAKE_CASE_:	Tuple            =ConvNextConfig()

   if "tiny" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	Dict            =[3, 3, 9, 3]
      SCREAMING_SNAKE_CASE_:	Dict            =[96, 192, 384, 768]
   if "small" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	Optional[int]            =[3, 3, 27, 3]
      SCREAMING_SNAKE_CASE_:	int            =[96, 192, 384, 768]
   if "base" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =[3, 3, 27, 3]
      SCREAMING_SNAKE_CASE_:	int            =[128, 256, 512, 1024]
   if "large" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	List[str]            =[3, 3, 27, 3]
      SCREAMING_SNAKE_CASE_:	List[str]            =[192, 384, 768, 1536]
   if "xlarge" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	int            =[3, 3, 27, 3]
      SCREAMING_SNAKE_CASE_:	List[str]            =[256, 512, 1024, 2048]

   if "1k" in checkpoint_url:
      SCREAMING_SNAKE_CASE_:	int            =1000
      SCREAMING_SNAKE_CASE_:	Optional[Any]            ="""imagenet-1k-id2label.json"""
      SCREAMING_SNAKE_CASE_:	Optional[Any]            =(1, 1000)
   else:
      SCREAMING_SNAKE_CASE_:	Dict            =2_1841
      SCREAMING_SNAKE_CASE_:	Tuple            ="""imagenet-22k-id2label.json"""
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =(1, 2_1841)

   SCREAMING_SNAKE_CASE_:	List[Any]            ="""huggingface/label-files"""
   SCREAMING_SNAKE_CASE_:	Tuple            =num_labels
   SCREAMING_SNAKE_CASE_:	List[Any]            =json.load(open(hf_hub_download(_lowerCAmelCase							,     _lowerCAmelCase							,     repo_type="""dataset"""	)							,     """r"""	)	)
   SCREAMING_SNAKE_CASE_:	Any            ={int(_lowerCAmelCase	): v for k, v in idalabel.items()}
   if "1k" not in checkpoint_url:
      # this dataset contains 21843 labels but the model only has 21841
      # we delete the classes as mentioned in https://github.com/google-research/big_transfer/issues/18
      del idalabel[9205]
      del idalabel[1_5027]
   SCREAMING_SNAKE_CASE_:	str            =idalabel
   SCREAMING_SNAKE_CASE_:	int            ={v: k for k, v in idalabel.items()}
   SCREAMING_SNAKE_CASE_:	Tuple            =hidden_sizes
   SCREAMING_SNAKE_CASE_:	Dict            =depths

   return config, expected_shape





def        __magic_name__			(							lowercase	):
   if "downsample_layers.0.0" in name:
      SCREAMING_SNAKE_CASE_:	List[str]            =name.replace("""downsample_layers.0.0"""							,     """embeddings.patch_embeddings"""	)
   if "downsample_layers.0.1" in name:
      SCREAMING_SNAKE_CASE_:	Optional[Any]            =name.replace("""downsample_layers.0.1"""							,     """embeddings.norm"""	)  # we rename to layernorm later on
   if "downsample_layers.1.0" in name:
      SCREAMING_SNAKE_CASE_:	Tuple            =name.replace("""downsample_layers.1.0"""							,     """stages.1.downsampling_layer.0"""	)
   if "downsample_layers.1.1" in name:
      SCREAMING_SNAKE_CASE_:	List[Any]            =name.replace("""downsample_layers.1.1"""							,     """stages.1.downsampling_layer.1"""	)
   if "downsample_layers.2.0" in name:
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =name.replace("""downsample_layers.2.0"""							,     """stages.2.downsampling_layer.0"""	)
   if "downsample_layers.2.1" in name:
      SCREAMING_SNAKE_CASE_:	Tuple            =name.replace("""downsample_layers.2.1"""							,     """stages.2.downsampling_layer.1"""	)
   if "downsample_layers.3.0" in name:
      SCREAMING_SNAKE_CASE_:	List[Any]            =name.replace("""downsample_layers.3.0"""							,     """stages.3.downsampling_layer.0"""	)
   if "downsample_layers.3.1" in name:
      SCREAMING_SNAKE_CASE_:	Optional[int]            =name.replace("""downsample_layers.3.1"""							,     """stages.3.downsampling_layer.1"""	)
   if "stages" in name and "downsampling_layer" not in name:
      # stages.0.0. for instance should be renamed to stages.0.layers.0.
      SCREAMING_SNAKE_CASE_:	Any            =name[: len("""stages.0"""	)] + """.layers""" + name[len("""stages.0"""	) :]
   if "stages" in name:
      SCREAMING_SNAKE_CASE_:	int            =name.replace("""stages"""							,     """encoder.stages"""	)
   if "norm" in name:
      SCREAMING_SNAKE_CASE_:	Optional[Any]            =name.replace("""norm"""							,     """layernorm"""	)
   if "gamma" in name:
      SCREAMING_SNAKE_CASE_:	Optional[Any]            =name.replace("""gamma"""							,     """layer_scale_parameter"""	)
   if "head" in name:
      SCREAMING_SNAKE_CASE_:	List[Any]            =name.replace("""head"""							,     """classifier"""	)

   return name





def        __magic_name__			(							):
   SCREAMING_SNAKE_CASE_:	List[Any]            ="""http://images.cocodataset.org/val2017/000000039769.jpg"""
   SCREAMING_SNAKE_CASE_:	Any            =Image.open(requests.get(_lowerCAmelCase							,     stream=_lowerCAmelCase	).raw	)
   return im





@torch.no_grad()
def        __magic_name__			(							lowercase							,     lowercase	):
   SCREAMING_SNAKE_CASE_     ,						SCREAMING_SNAKE_CASE_:	Dict            =get_convnext_config(_lowerCAmelCase	)
   # load original state_dict from URL
   SCREAMING_SNAKE_CASE_:	int            =torch.hub.load_state_dict_from_url(_lowerCAmelCase	)["""model"""]
   # rename keys
   for key in state_dict.copy().keys():
      SCREAMING_SNAKE_CASE_:	Optional[int]            =state_dict.pop(_lowerCAmelCase	)
      SCREAMING_SNAKE_CASE_:	Tuple            =val
   # add prefix to all keys expect classifier head
   for key in state_dict.copy().keys():
      SCREAMING_SNAKE_CASE_:	List[str]            =state_dict.pop(_lowerCAmelCase	)
      if not key.startswith("""classifier"""	):
         SCREAMING_SNAKE_CASE_:	str            ="""convnext.""" + key
      SCREAMING_SNAKE_CASE_:	Any            =val

   # load HuggingFace model
   SCREAMING_SNAKE_CASE_:	Any            =ConvNextForImageClassification(_lowerCAmelCase	)
   model.load_state_dict(_lowerCAmelCase	)
   model.eval()

   # Check outputs on an image, prepared by ConvNextImageProcessor
   SCREAMING_SNAKE_CASE_:	Union[str, Any]            =224 if """224""" in checkpoint_url else 384
   SCREAMING_SNAKE_CASE_:	str            =ConvNextImageProcessor(size=_lowerCAmelCase	)
   SCREAMING_SNAKE_CASE_:	Dict            =image_processor(images=prepare_img()							,     return_tensors="""pt"""	).pixel_values

   SCREAMING_SNAKE_CASE_:	Optional[int]            =model(_lowerCAmelCase	).logits

   # note: the logits below were obtained without center cropping
   if checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth":
      SCREAMING_SNAKE_CASE_:	int            =torch.tensor([-0.1_210, -0.6_605, 0.1_918]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_small_1k_224_ema.pth":
      SCREAMING_SNAKE_CASE_:	int            =torch.tensor([-0.4_473, -0.1_847, -0.6_365]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_224_ema.pth":
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =torch.tensor([0.4_525, 0.7_539, 0.0_308]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_384.pth":
      SCREAMING_SNAKE_CASE_:	List[Any]            =torch.tensor([0.3_561, 0.6_350, -0.0_384]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_224_ema.pth":
      SCREAMING_SNAKE_CASE_:	str            =torch.tensor([0.4_174, -0.0_989, 0.1_489]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_384.pth":
      SCREAMING_SNAKE_CASE_:	List[str]            =torch.tensor([0.2_513, -0.1_349, -0.1_613]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_224.pth":
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =torch.tensor([1.2_980, 0.3_631, -0.1_198]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_224.pth":
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =torch.tensor([1.2_963, 0.1_227, 0.1_723]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_224.pth":
      SCREAMING_SNAKE_CASE_:	Any            =torch.tensor([1.7_956, 0.8_390, 0.2_820]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_224.pth":
      SCREAMING_SNAKE_CASE_:	List[Any]            =torch.tensor([-0.2_822, -0.0_502, -0.0_878]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_384.pth":
      SCREAMING_SNAKE_CASE_:	str            =torch.tensor([-0.5_672, -0.0_730, -0.4_348]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_224.pth":
      SCREAMING_SNAKE_CASE_:	Union[str, Any]            =torch.tensor([0.2_681, 0.2_365, 0.6_246]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_384.pth":
      SCREAMING_SNAKE_CASE_:	Any            =torch.tensor([-0.2_642, 0.3_931, 0.5_116]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_224_ema.pth":
      SCREAMING_SNAKE_CASE_:	int            =torch.tensor([-0.6_677, -0.1_873, -0.8_379]	)
   elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_384_ema.pth":
      SCREAMING_SNAKE_CASE_:	str            =torch.tensor([-0.7_749, -0.2_967, -0.6_444]	)
   else:
      raise ValueError(f'''Unknown URL: {checkpoint_url}'''	)

   assert torch.allclose(logits[0, :3]							,     _lowerCAmelCase							,     atol=1e-3	)
   assert logits.shape == expected_shape

   Path(_lowerCAmelCase	).mkdir(exist_ok=_lowerCAmelCase	)
   print(f'''Saving model to {pytorch_dump_folder_path}'''	)
   model.save_pretrained(_lowerCAmelCase	)
   print(f'''Saving image processor to {pytorch_dump_folder_path}'''	)
   image_processor.save_pretrained(_lowerCAmelCase	)

   print("""Pushing model to the hub..."""	)
   SCREAMING_SNAKE_CASE_:	Tuple            ="""convnext"""
   if "tiny" in checkpoint_url:
      model_name += "-tiny"
   elif "small" in checkpoint_url:
      model_name += "-small"
   elif "base" in checkpoint_url:
      model_name += "-base"
   elif "xlarge" in checkpoint_url:
      model_name += "-xlarge"
   elif "large" in checkpoint_url:
      model_name += "-large"
   if "224" in checkpoint_url:
      model_name += "-224"
   elif "384" in checkpoint_url:
      model_name += "-384"
   if "22k" in checkpoint_url and "1k" not in checkpoint_url:
      model_name += "-22k"
   if "22k" in checkpoint_url and "1k" in checkpoint_url:
      model_name += "-22k-1k"

   model.push_to_hub(
       repo_path_or_name=Path(_lowerCAmelCase							,     _lowerCAmelCase	)							,     organization="""nielsr"""							,     commit_message="""Add model"""							,     )


if __name__ == "__main__":
   _UpperCAmelCase       =     argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       """--checkpoint_url""",
       default="""https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth""",
       type=str,
       help="""URL of the original ConvNeXT checkpoint you'd like to convert.""",
   )
   parser.add_argument(
       """--pytorch_dump_folder_path""",
       default=None,
       type=str,
       required=True,
       help="""Path to the output PyTorch model directory.""",
   )

   _UpperCAmelCase       =     parser.parse_args()
   convert_convnext_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)









"""simple docstring"""
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


_UpperCAmelCase       =     5_0_3_5_8
_UpperCAmelCase       =     5_0_3_6_2
@require_torch
@require_torchaudio
@require_sentencepiece
class    a		(					unittest.TestCase    ):



  def 		lowerCamelCase__    (  self	:   Dict						)       ->   Tuple:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	List[Any]            ="""openai/whisper-small.en"""
     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =tempfile.mkdtemp()



  def 		lowerCamelCase__    (  self	:   Any    ,						**lowerCAmelCase	:   str						)       ->   str:


     '''simple docstring'''




     return WhisperTokenizer.from_pretrained(self.checkpoint    ,						**lowerCAmelCase						)



  def 		lowerCamelCase__    (  self	:   str    ,						**lowerCAmelCase	:   Optional[Any]						)       ->   Optional[Any]:


     '''simple docstring'''




     return WhisperFeatureExtractor.from_pretrained(self.checkpoint    ,						**lowerCAmelCase						)



  def 		lowerCamelCase__    (  self	:   Tuple						)       ->   Optional[Any]:


     '''simple docstring'''




     shutil.rmtree(self.tmpdirname						)



  def 		lowerCamelCase__    (  self	:   int						)       ->   str:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Optional[int]            =self.get_tokenizer()
     SCREAMING_SNAKE_CASE_:	Optional[int]            =self.get_feature_extractor()

     SCREAMING_SNAKE_CASE_:	Optional[Any]            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)

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

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

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



  def 		lowerCamelCase__    (  self	:   str						)       ->   Optional[Any]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =WhisperProcessor(tokenizer=self.get_tokenizer()    ,						feature_extractor=self.get_feature_extractor()						)
     processor.save_pretrained(self.tmpdirname						)

     SCREAMING_SNAKE_CASE_:	int            =self.get_tokenizer(bos_token="""(BOS)"""    ,						eos_token="""(EOS)"""						)
     SCREAMING_SNAKE_CASE_:	Dict            =self.get_feature_extractor(do_normalize=lowerCAmelCase    ,						padding_value=1.0						)

     SCREAMING_SNAKE_CASE_:	Optional[int]            =WhisperProcessor.from_pretrained(
         self.tmpdirname    ,						bos_token="""(BOS)"""    ,						eos_token="""(EOS)"""    ,						do_normalize=lowerCAmelCase    ,						padding_value=1.0						)

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

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



  def 		lowerCamelCase__    (  self	:   Tuple						)       ->   Optional[int]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Tuple            =self.get_feature_extractor()
     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =self.get_tokenizer()

     SCREAMING_SNAKE_CASE_:	Dict            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)

     SCREAMING_SNAKE_CASE_:	Dict            =floats_list((3, 1000)						)

     SCREAMING_SNAKE_CASE_:	Optional[Any]            =feature_extractor(lowerCAmelCase    ,						return_tensors="""np"""						)
     SCREAMING_SNAKE_CASE_:	str            =processor(lowerCAmelCase    ,						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 		lowerCamelCase__    (  self	:   Tuple						)       ->   Any:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	List[str]            =self.get_feature_extractor()
     SCREAMING_SNAKE_CASE_:	str            =self.get_tokenizer()

     SCREAMING_SNAKE_CASE_:	List[Any]            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)

     SCREAMING_SNAKE_CASE_:	List[str]            ="""This is a test string"""

     SCREAMING_SNAKE_CASE_:	Tuple            =processor(text=lowerCAmelCase						)

     SCREAMING_SNAKE_CASE_:	List[Any]            =tokenizer(lowerCAmelCase						)

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



  def 		lowerCamelCase__    (  self	:   Optional[Any]						)       ->   Any:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Optional[int]            =self.get_feature_extractor()
     SCREAMING_SNAKE_CASE_:	str            =self.get_tokenizer()

     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)

     SCREAMING_SNAKE_CASE_:	List[str]            =[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

     SCREAMING_SNAKE_CASE_:	Optional[int]            =processor.batch_decode(lowerCAmelCase						)
     SCREAMING_SNAKE_CASE_:	Dict            =tokenizer.batch_decode(lowerCAmelCase						)

     self.assertListEqual(lowerCAmelCase    ,						lowerCAmelCase						)



  def 		lowerCamelCase__    (  self	:   Union[str, Any]						)       ->   Dict:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	str            =self.get_feature_extractor()
     SCREAMING_SNAKE_CASE_:	List[Any]            =self.get_tokenizer()

     SCREAMING_SNAKE_CASE_:	Optional[Any]            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)

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



  def 		lowerCamelCase__    (  self	:   Optional[int]						)       ->   Union[str, Any]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Optional[Any]            =self.get_feature_extractor()
     SCREAMING_SNAKE_CASE_:	Any            =self.get_tokenizer()

     SCREAMING_SNAKE_CASE_:	List[Any]            =WhisperProcessor(tokenizer=lowerCAmelCase    ,						feature_extractor=lowerCAmelCase						)
     SCREAMING_SNAKE_CASE_:	Any            =processor.get_decoder_prompt_ids(task="""transcribe"""    ,						no_timestamps=lowerCAmelCase						)

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

     SCREAMING_SNAKE_CASE_:	Tuple            =[TRANSCRIBE, NOTIMESTAMPS]
     self.assertListEqual([ids[-1] for ids in forced_decoder_ids]    ,						lowerCAmelCase						)



  def 		lowerCamelCase__    (  self	:   List[str]						)       ->   List[str]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =WhisperProcessor(tokenizer=self.get_tokenizer()    ,						feature_extractor=self.get_feature_extractor()						)
     SCREAMING_SNAKE_CASE_:	Optional[int]            =processor.get_prompt_ids("""Mr. Quilter"""						)
     SCREAMING_SNAKE_CASE_:	List[str]            =processor.tokenizer.decode(lowerCAmelCase						)

     self.assertListEqual(prompt_ids.tolist()    ,						[5_0360, 1770, 13, 2264, 346, 353]						)
     self.assertEqual(lowerCAmelCase    ,						"""<|startofprev|> Mr. Quilter"""						)



  def 		lowerCamelCase__    (  self	:   Dict						)       ->   Tuple:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Optional[Any]            =WhisperProcessor(tokenizer=self.get_tokenizer()    ,						feature_extractor=self.get_feature_extractor()						)
     SCREAMING_SNAKE_CASE_:	int            =processor.get_prompt_ids(""""""						)
     SCREAMING_SNAKE_CASE_:	Union[str, Any]            =processor.tokenizer.decode(lowerCAmelCase						)

     self.assertListEqual(prompt_ids.tolist()    ,						[5_0360, 220]						)
     self.assertEqual(lowerCAmelCase    ,						"""<|startofprev|> """						)





  def 		lowerCamelCase__    (  self	:   Optional[int]						)       ->   Any:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_:	Dict            =WhisperProcessor(tokenizer=self.get_tokenizer()    ,						feature_extractor=self.get_feature_extractor()						)

     def _test_prompt_error_raised_helper(lowerCAmelCase	:   List[str]    ,						lowerCAmelCase	:   int						):
        with pytest.raises(lowerCAmelCase						) as excinfo:
           processor.get_prompt_ids(lowerCAmelCase						)
        SCREAMING_SNAKE_CASE_:	List[Any]            =f'''Encountered text in the prompt corresponding to disallowed special token: {special_token}.'''
        self.assertEqual(lowerCAmelCase    ,						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|>"""						)



