





'''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						(					__lowerCamelCase			:   int   )						->list[int]:
    return [int(__lowerCamelCase   ) for c in F'{ruleset:08}'[:8]]





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





def lowerCamelCase						(					__lowerCamelCase			:   list[list[int]]   )						->Image.Image:
    _SCREAMING_SNAKE_CASE     =      Image.new("""RGB""" ,	(len(cells[0]   ), len(__lowerCamelCase   ))   )
    _SCREAMING_SNAKE_CASE     =      img.load()
    # Generates image
    for w in range(img.width   ):
        for h in range(img.height   ):
            _SCREAMING_SNAKE_CASE     =      255 - int(255 * cells[h][w]   )
            _SCREAMING_SNAKE_CASE     =      (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()











'''simple docstring'''

from typing import TYPE_CHECKING

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


lowercase_         =			{
    """configuration_esm""": ["""ESM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """EsmConfig"""],
    """tokenization_esm""": ["""EsmTokenizer"""],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			[
          """ESM_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """EsmForMaskedLM""",
          """EsmForSequenceClassification""",
          """EsmForTokenClassification""",
          """EsmModel""",
          """EsmPreTrainedModel""",
      ]
      lowercase_         =			["""EsmForProteinFolding""", """EsmFoldPreTrainedModel"""]

try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_         =			[
          """TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """TFEsmForMaskedLM""",
          """TFEsmForSequenceClassification""",
          """TFEsmForTokenClassification""",
          """TFEsmModel""",
          """TFEsmPreTrainedModel""",
      ]

if TYPE_CHECKING:
      from .configuration_esm import ESM_PRETRAINED_CONFIG_ARCHIVE_MAP, EsmConfig
      from .tokenization_esm import EsmTokenizer

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_esm import (
                ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
                EsmForMaskedLM,
                EsmForSequenceClassification,
                EsmForTokenClassification,
                EsmModel,
                EsmPreTrainedModel,
            )
            from .modeling_esmfold import EsmFoldPreTrainedModel, EsmForProteinFolding

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_esm import (
                TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
                TFEsmForMaskedLM,
                TFEsmForSequenceClassification,
                TFEsmForTokenClassification,
                TFEsmModel,
                TFEsmPreTrainedModel,
            )


else:
      import sys

      lowercase_         =			_LazyModule(__name__, globals()["""__file__"""], _import_structure)



