




from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
lowercase_     :    Dict      =			[[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 							__SCREAMING_SNAKE_CASE  (      snake_case_						):

						'''simple docstring'''


						return [int(snake_case_						) for c in f"""{ruleset:08}"""[:8]]


def 							__SCREAMING_SNAKE_CASE  (      snake_case_     ,   snake_case_     ,   snake_case_						):

						'''simple docstring'''


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


def 							__SCREAMING_SNAKE_CASE  (      snake_case_						):

						'''simple docstring'''


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


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










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowercase_     :    int      =			{
    'configuration_videomae': ['VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VideoMAEConfig'],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowercase_     :    List[str]      =			[
				    'VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'VideoMAEForPreTraining',
				    'VideoMAEModel',
				    'VideoMAEPreTrainedModel',
				    'VideoMAEForVideoClassification',
				]

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowercase_     :    Any      =			['VideoMAEFeatureExtractor']
				lowercase_     :    Dict      =			['VideoMAEImageProcessor']

if TYPE_CHECKING:
				from .configuration_videomae import VIDEOMAE_PRETRAINED_CONFIG_ARCHIVE_MAP, VideoMAEConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_videomae import (
								    VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST,
								    VideoMAEForPreTraining,
								    VideoMAEForVideoClassification,
								    VideoMAEModel,
								    VideoMAEPreTrainedModel,
								)

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_videomae import VideoMAEFeatureExtractor
								from .image_processing_videomae import VideoMAEImageProcessor

else:
				import sys

				lowercase_     :    int      =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




