






"""simple docstring"""



from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
_UpperCamelCase		:  Any						=		[[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      :  int   ):





  '''simple docstring'''





  return [int(__snake_case   ) for c in f'{ruleset:08}'[:8]]
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  list[list[int]]		, __snake_case      :  list[int]		, __snake_case      :  int   ):





  '''simple docstring'''





  lowercase							   =	len(cells[0]   )  # 31
  lowercase							   =	[]
  for i in range(__snake_case   ):
    # Get the neighbors of each cell
    # Handle neighbours outside bounds by using 0 as their value
    lowercase							   =	0 if i == 0 else cells[time][i - 1]
    lowercase							   =	0 if i == population - 1 else cells[time][i + 1]
    # Define a new cell and add it to the new generation
    lowercase							   =	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      :  list[list[int]]   ):





  '''simple docstring'''





  lowercase							   =	Image.new('RGB'		, (len(cells[0]   ), len(__snake_case   ))   )
  lowercase							   =	img.load()
  # Generates image
  for w in range(img.width   ):
    for h in range(img.height   ):
      lowercase							   =	2_55 - int(2_55 * cells[h][w]   )
      lowercase							   =	(color, color, color)
  return img


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










"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCamelCase		:  str						=		{
    'configuration_wav2vec2_conformer': [
        'WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Wav2Vec2ConformerConfig',
    ],
}


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _UpperCamelCase		:  str						=		[
        'WAV2VEC2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
        'Wav2Vec2ConformerForAudioFrameClassification',
        'Wav2Vec2ConformerForCTC',
        'Wav2Vec2ConformerForPreTraining',
        'Wav2Vec2ConformerForSequenceClassification',
        'Wav2Vec2ConformerForXVector',
        'Wav2Vec2ConformerModel',
        'Wav2Vec2ConformerPreTrainedModel',
    ]

if TYPE_CHECKING:
    from .configuration_wavaveca_conformer import (
        WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
        WavaVecaConformerConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_wavaveca_conformer import (
            WAV2VEC2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            WavaVecaConformerForAudioFrameClassification,
            WavaVecaConformerForCTC,
            WavaVecaConformerForPreTraining,
            WavaVecaConformerForSequenceClassification,
            WavaVecaConformerForXVector,
            WavaVecaConformerModel,
            WavaVecaConformerPreTrainedModel,
        )

else:
    import sys

    _UpperCamelCase		:  Union[str, Any]						=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


