



from __future__ import annotations

from PIL import Image

# Define glider example
UpperCAmelCase							 =					[
    [0, 1, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0, 0],
    [1, 1, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
]

# Define blinker example
UpperCAmelCase							 =					[[0, 1, 0], [0, 1, 0], [0, 1, 0]]

def 			A_      (	__a     :				Any		):

				"""simple docstring"""
				a__				      =		[]
				for i in range(len(lowercase__		)		):
								a__				      =		[]
								for j in range(len(cells[i]		)		):
												# Get the number of live neighbours
												a__				      =		0
												if i > 0 and j > 0:
																neighbour_count += cells[i - 1][j - 1]
												if i > 0:
																neighbour_count += cells[i - 1][j]
												if i > 0 and j < len(cells[i]		) - 1:
																neighbour_count += cells[i - 1][j + 1]
												if j > 0:
																neighbour_count += cells[i][j - 1]
												if j < len(cells[i]		) - 1:
																neighbour_count += cells[i][j + 1]
												if i < len(lowercase__		) - 1 and j > 0:
																neighbour_count += cells[i + 1][j - 1]
												if i < len(lowercase__		) - 1:
																neighbour_count += cells[i + 1][j]
												if i < len(lowercase__		) - 1 and j < len(cells[i]		) - 1:
																neighbour_count += cells[i + 1][j + 1]

												# Rules of the game of life (excerpt from Wikipedia):
												# 1. Any live cell with two or three live neighbours survives.
												# 2. Any dead cell with three live neighbours becomes a live cell.
												# 3. All other live cells die in the next generation.
												#    Similarly, all other dead cells stay dead.
												a__				      =		cells[i][j] == 1
												if (
												    (alive and 2 <= neighbour_count <= 3)
												    or not alive
												    and neighbour_count == 3
												):
																next_generation_row.append(1		)
												else:
																next_generation_row.append(0		)

								next_generation.append(lowercase__		)
				return next_generation

def 			A_      (	__a     :				Dict ,		__a     :				List[str]		):

				"""simple docstring"""
				a__				      =		[]
				for _ in range(lowercase__		):
								# Create output image
								a__				      =		Image.new("""RGB""" ,		(len(cells[0]		), len(lowercase__		))		)
								a__				      =		img.load()

								# Save cells to image
								for x in range(len(lowercase__		)		):
												for y in range(len(cells[0]		)		):
																a__				      =		255 - cells[y][x] * 255
																a__				      =		(colour, colour, colour)

        # Save image
								images.append(lowercase__		)
								a__				      =		new_generation(lowercase__		)
				return images


if __name__ == "__main__":
	UpperCAmelCase							 =					generate_images(GLIDER, 16)
	images[0].save("""out.gif""", save_all=True, append_images=images[1:])






# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script dumps information about the environment

import os
import sys

import transformers


UpperCAmelCase							 =					"""3"""

print("""Python version:""", sys.version)
print("""transformers version:""", transformers.__version__)

try:
	import torch

	print("""Torch version:""", torch.__version__)
	print("""Cuda available:""", torch.cuda.is_available())
	print("""Cuda version:""", torch.version.cuda)
	print("""CuDNN version:""", torch.backends.cudnn.version())
	print("""Number of GPUs available:""", torch.cuda.device_count())
	print("""NCCL version:""", torch.cuda.nccl.version())
except ImportError:
	print("""Torch version:""", None)

try:
	import deepspeed

	print("""DeepSpeed version:""", deepspeed.__version__)
except ImportError:
	print("""DeepSpeed version:""", None)

try:
	import tensorflow as tf

	print("""TensorFlow version:""", tf.__version__)
	print("""TF GPUs available:""", bool(tf.config.list_physical_devices("""GPU""")))
	print("""Number of TF GPUs available:""", len(tf.config.list_physical_devices("""GPU""")))
except ImportError:
	print("""TensorFlow version:""", None)

