"""simple docstring"""

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__lowercase      					=							logging.get_logger(__name__)

__lowercase      					=							{
    'nghuyong/ernie-1.0-base-zh': 'https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json',
    'nghuyong/ernie-2.0-base-en': 'https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json',
    'nghuyong/ernie-2.0-large-en': 'https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json',
    'nghuyong/ernie-3.0-base-zh': 'https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-medium-zh': 'https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-mini-zh': 'https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-micro-zh': 'https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-nano-zh': 'https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json',
    'nghuyong/ernie-gram-zh': 'https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json',
    'nghuyong/ernie-health-zh': 'https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json',
}






class 						_lowercase      (		__snake_case	):



						"""simple docstring"""




						lowercase__  					=   '''ernie'''





						def __init__(							self				:  Optional[Any]			,      UpperCamelCase__				:  int=30522			,      UpperCamelCase__				:  Optional[int]=768			,      UpperCamelCase__				:  Dict=12			,      UpperCamelCase__				:  Optional[int]=12			,      UpperCamelCase__				:  int=3072			,      UpperCamelCase__				:  List[Any]="gelu"			,      UpperCamelCase__				:  int=0.1			,      UpperCamelCase__				:  List[str]=0.1			,      UpperCamelCase__				:  int=512			,      UpperCamelCase__				:  int=2			,      UpperCamelCase__				:  Any=3			,      UpperCamelCase__				:  Optional[int]=False			,      UpperCamelCase__				:  List[Any]=0.02			,      UpperCamelCase__				:  List[Any]=1E-12			,      UpperCamelCase__				:  List[Any]=0			,      UpperCamelCase__				:  Tuple="absolute"			,      UpperCamelCase__				:  Any=True			,      UpperCamelCase__				:  List[Any]=None			,      **UpperCamelCase__				:  List[str]			,      )							->							List[Any]:
													'''simple docstring'''



													super().__init__(pad_token_id=lowercase_			,      **lowercase_							)

													__UpperCamelCase		     =vocab_size
													__UpperCamelCase		     =hidden_size
													__UpperCamelCase		     =num_hidden_layers
													__UpperCamelCase		     =num_attention_heads
													__UpperCamelCase		     =hidden_act
													__UpperCamelCase		     =intermediate_size
													__UpperCamelCase		     =hidden_dropout_prob
													__UpperCamelCase		     =attention_probs_dropout_prob
													__UpperCamelCase		     =max_position_embeddings
													__UpperCamelCase		     =type_vocab_size
													__UpperCamelCase		     =task_type_vocab_size
													__UpperCamelCase		     =use_task_id
													__UpperCamelCase		     =initializer_range
													__UpperCamelCase		     =layer_norm_eps
													__UpperCamelCase		     =position_embedding_type
													__UpperCamelCase		     =use_cache
													__UpperCamelCase		     =classifier_dropout






class 						_lowercase      (		__snake_case	):



						"""simple docstring"""




						@property
						def    UpperCAmelCase_      (							self				:  Optional[Any]							)							->							Dict:
													'''simple docstring'''



													if self.task == "multiple-choice":
																				__UpperCamelCase		     ={0: "batch", 1: "choice", 2: "sequence"}
													else:
																				__UpperCamelCase		     ={0: "batch", 1: "sequence"}
													return OrderedDict(
													    [
													        ('''input_ids''', dynamic_axis),
													        ('''attention_mask''', dynamic_axis),
													        ('''token_type_ids''', dynamic_axis),
													        ('''task_type_ids''', dynamic_axis),
													    ]							)




from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
__SCREAMING_SNAKE_CASE						:    Optional[int]     = [[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 					snake_case						(__lowercase						)       ->       list[int]:

						'''simple docstring'''



						return [int(__lowercase						) for c in F"""{ruleset:08}"""[:8]]
def 					snake_case						(__lowercase					,			__lowercase					,			__lowercase						)       ->       list[int]:

						'''simple docstring'''



						_snake_case						:     Any				=    len(cells[0]						)  # 31
						_snake_case						:     str				=    []
						for i in range(__lowercase						):
												# Get the neighbors of each cell
												# Handle neighbours outside bounds by using 0 as their value
												_snake_case						:     Any				=    0 if i == 0 else cells[time][i - 1]
												_snake_case						:     List[str]				=    0 if i == population - 1 else cells[time][i + 1]
												# Define a new cell and add it to the new generation
												_snake_case						:     str				=    7 - int(F"""{left_neighbor}{cells[time][i]}{right_neighbor}"""					,			2						)
												next_generation.append(rule[situation]						)
						return next_generation
def 					snake_case						(__lowercase						)       ->       Image.Image:

						'''simple docstring'''



						_snake_case						:     str				=    Image.new("RGB"					,			(len(cells[0]						), len(__lowercase						))						)
						_snake_case						:     int				=    img.load()
						# Generates image
						for w in range(img.width						):
												for h in range(img.height						):
																		_snake_case						:     List[Any]				=    255 - int(255 * cells[h][w]						)
																		_snake_case						:     Union[str, Any]				=    (color, color, color)
						return img


if __name__ == "__main__":
				__SCREAMING_SNAKE_CASE						:    Any     = bin(int(input('Rule:\n').strip()))[2:]
				__SCREAMING_SNAKE_CASE						:    Tuple     = format_ruleset(int(rule_num))
				for time in range(1_6):
								CELLS.append(new_generation(CELLS, rule, time))
				__SCREAMING_SNAKE_CASE						:    List[Any]     = generate_image(CELLS)
				# Uncomment to save the image
				# img.save(f"rule_{rule_num}.png")
				img.show()