code: 
  
  
  
  
  
  
  """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
  
  
  lowercase__      =				50358
  lowercase__      =				50362
  
  
  
  
  
  
  
  @require_torch
  @require_torchaudio
  @require_sentencepiece
  class 	__lowerCamelCase       (				unittest.TestCase    ):
  
  
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Dict			):
  				lowerCAmelCase_     :							List[str]             =    "openai/whisper-small.en"
  				lowerCAmelCase_     :							Tuple             =    tempfile.mkdtemp()
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Any		,    **a_							:			Optional[int]			):
  				return WhisperTokenizer.from_pretrained(self.checkpoint		,    **a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			List[str]		,    **a_							:			Optional[int]			):
  				return WhisperFeatureExtractor.from_pretrained(self.checkpoint		,    **a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			int			):
  				shutil.rmtree(self.tmpdirname			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Optional[int]			):
  				lowerCAmelCase_     :							str             =    self.get_tokenizer()
  				lowerCAmelCase_     :							Dict             =    self.get_feature_extractor()
  
  				lowerCAmelCase_     :							Any             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  
  				processor.save_pretrained(self.tmpdirname			)
  				lowerCAmelCase_     :							List[Any]             =    WhisperProcessor.from_pretrained(self.tmpdirname			)
  
  				self.assertEqual(processor.tokenizer.get_vocab()		,    tokenizer.get_vocab()			)
  				self.assertIsInstance(processor.tokenizer		,    a_			)
  
  				self.assertEqual(processor.feature_extractor.to_json_string()		,    feature_extractor.to_json_string()			)
  				self.assertIsInstance(processor.feature_extractor		,    a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Any			):
  				lowerCAmelCase_     :							Tuple             =    WhisperProcessor(tokenizer=self.get_tokenizer()		,    feature_extractor=self.get_feature_extractor()			)
  				processor.save_pretrained(self.tmpdirname			)
  
  				lowerCAmelCase_     :							Union[str, Any]             =    self.get_tokenizer(bos_token="(BOS)"		,    eos_token="(EOS)"			)
  				lowerCAmelCase_     :							List[str]             =    self.get_feature_extractor(do_normalize=a_		,    padding_value=1.0			)
  
  				lowerCAmelCase_     :							Union[str, Any]             =    WhisperProcessor.from_pretrained(
  				    self.tmpdirname		,    bos_token="(BOS)"		,    eos_token="(EOS)"		,    do_normalize=a_		,    padding_value=1.0			)
  
  				self.assertEqual(processor.tokenizer.get_vocab()		,    tokenizer_add_kwargs.get_vocab()			)
  				self.assertIsInstance(processor.tokenizer		,    a_			)
  
  				self.assertEqual(processor.feature_extractor.to_json_string()		,    feature_extractor_add_kwargs.to_json_string()			)
  				self.assertIsInstance(processor.feature_extractor		,    a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			List[Any]			):
  				lowerCAmelCase_     :							List[str]             =    self.get_feature_extractor()
  				lowerCAmelCase_     :							Optional[Any]             =    self.get_tokenizer()
  
  				lowerCAmelCase_     :							int             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  
  				lowerCAmelCase_     :							Any             =    floats_list((3, 10_00)			)
  
  				lowerCAmelCase_     :							Dict             =    feature_extractor(a_		,    return_tensors="np"			)
  				lowerCAmelCase_     :							Dict             =    processor(a_		,    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							:			List[str]			):
  				lowerCAmelCase_     :							List[str]             =    self.get_feature_extractor()
  				lowerCAmelCase_     :							str             =    self.get_tokenizer()
  
  				lowerCAmelCase_     :							Dict             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  
  				lowerCAmelCase_     :							Any             =    "This is a test string"
  
  				lowerCAmelCase_     :							str             =    processor(text=a_			)
  
  				lowerCAmelCase_     :							Union[str, Any]             =    tokenizer(a_			)
  
  				for key in encoded_tok.keys():
  						self.assertListEqual(encoded_tok[key]		,    encoded_processor[key]			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Optional[int]			):
  				lowerCAmelCase_     :							List[str]             =    self.get_feature_extractor()
  				lowerCAmelCase_     :							List[Any]             =    self.get_tokenizer()
  
  				lowerCAmelCase_     :							Optional[Any]             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  
  				lowerCAmelCase_     :							int             =    [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]
  
  				lowerCAmelCase_     :							Optional[int]             =    processor.batch_decode(a_			)
  				lowerCAmelCase_     :							Optional[int]             =    tokenizer.batch_decode(a_			)
  
  				self.assertListEqual(a_		,    a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Dict			):
  				lowerCAmelCase_     :							Optional[Any]             =    self.get_feature_extractor()
  				lowerCAmelCase_     :							Union[str, Any]             =    self.get_tokenizer()
  
  				lowerCAmelCase_     :							Dict             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  
  				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							:			List[str]			):
  				lowerCAmelCase_     :							Dict             =    self.get_feature_extractor()
  				lowerCAmelCase_     :							Any             =    self.get_tokenizer()
  
  				lowerCAmelCase_     :							Dict             =    WhisperProcessor(tokenizer=a_		,    feature_extractor=a_			)
  				lowerCAmelCase_     :							Tuple             =    processor.get_decoder_prompt_ids(task="transcribe"		,    no_timestamps=a_			)
  
  				self.assertIsInstance(a_		,    a_			)
  				for ids in forced_decoder_ids:
  						self.assertIsInstance(a_		,    (list, tuple)			)
  
  				lowerCAmelCase_     :							int             =    [TRANSCRIBE, NOTIMESTAMPS]
  				self.assertListEqual([ids[-1] for ids in forced_decoder_ids]		,    a_			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			Dict			):
  				lowerCAmelCase_     :							List[str]             =    WhisperProcessor(tokenizer=self.get_tokenizer()		,    feature_extractor=self.get_feature_extractor()			)
  				lowerCAmelCase_     :							Any             =    processor.get_prompt_ids("Mr. Quilter"			)
  				lowerCAmelCase_     :							int             =    processor.tokenizer.decode(a_			)
  
  				self.assertListEqual(prompt_ids.tolist()		,    [5_03_60, 17_70, 13, 22_64, 3_46, 3_53]			)
  				self.assertEqual(a_		,    "<|startofprev|> Mr. Quilter"			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			str			):
  				lowerCAmelCase_     :							Optional[Any]             =    WhisperProcessor(tokenizer=self.get_tokenizer()		,    feature_extractor=self.get_feature_extractor()			)
  				lowerCAmelCase_     :							Optional[Any]             =    processor.get_prompt_ids(""			)
  				lowerCAmelCase_     :							Tuple             =    processor.tokenizer.decode(a_			)
  
  				self.assertListEqual(prompt_ids.tolist()		,    [5_03_60, 2_20]			)
  				self.assertEqual(a_		,    "<|startofprev|> "			)
  
  
  
  
  
  		def      lowerCamelCase (     self							:			List[Any]			):
  				lowerCAmelCase_     :							Optional[Any]             =    WhisperProcessor(tokenizer=self.get_tokenizer()		,    feature_extractor=self.get_feature_extractor()			)
  
  				def _test_prompt_error_raised_helper(a_							:			List[Any]		,    a_							:			Union[str, Any]			):
  						with pytest.raises(a_			) as excinfo:
  								processor.get_prompt_ids(a_			)
  						lowerCAmelCase_     :							Any             =    f'''Encountered text in the prompt corresponding to disallowed special token: {special_token}.'''
  						self.assertEqual(a_		,    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|>"			)
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  from __future__ import annotations
  
  from PIL import Image
  
  # Define the first generation of cells
  # fmt: off
  lowercase__      =				[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
  
  def 	__lowerCamelCase			(						__UpperCamelCase )		->					list[int]:
  
  		"""simple docstring"""
  
  
  
  
  
  
  
  		return [int(__UpperCamelCase ) for c in f'''{ruleset:08}'''[:8]]
  
  def 	__lowerCamelCase			(						__UpperCamelCase   , __UpperCamelCase   , __UpperCamelCase )		->					list[int]:
  
  		"""simple docstring"""
  
  
  
  
  
  
  
  		lowerCAmelCase_     :							int             =    len(cells[0] )  # 31
  		lowerCAmelCase_     :							List[Any]             =    []
  		for i in range(__UpperCamelCase ):
  				# Get the neighbors of each cell
  				# Handle neighbours outside bounds by using 0 as their value
  				lowerCAmelCase_     :							List[str]             =    0 if i == 0 else cells[time][i - 1]
  				lowerCAmelCase_     :							Optional[int]             =    0 if i == population - 1 else cells[time][i + 1]
  				# Define a new cell and add it to the new generation
  				lowerCAmelCase_     :							List[Any]             =    7 - int(f'''{left_neighbor}{cells[time][i]}{right_neighbor}'''   , 2 )
  				next_generation.append(rule[situation] )
  		return next_generation
  
  def 	__lowerCamelCase			(						__UpperCamelCase )		->					Image.Image:
  
  		"""simple docstring"""
  
  
  
  
  
  
  
  		lowerCAmelCase_     :							List[str]             =    Image.new("RGB"   , (len(cells[0] ), len(__UpperCamelCase )) )
  		lowerCAmelCase_     :							List[str]             =    img.load()
  		# Generates image
  		for w in range(img.width ):
  				for h in range(img.height ):
  						lowerCAmelCase_     :							Union[str, Any]             =    255 - int(255 * cells[h][w] )
  						lowerCAmelCase_     :							List[str]             =    (color, color, color)
  		return img
  
  
  if __name__ == "__main__":
  					lowercase__      =				bin(int(input("""Rule:\n""").strip()))[2:]
  					lowercase__      =				format_ruleset(int(rule_num))
  					for time in range(16):
  										CELLS.append(new_generation(CELLS, rule, time))
  					lowercase__      =				generate_image(CELLS)
  					# Uncomment to save the image
  					# img.save(f"rule_{rule_num}.png")
  					img.show()
  