




"""simple docstring"""

import sys

sys.set_int_max_str_digits(0)  # type: ignore




def    snake_case__						(							lowerCAmelCase :		int		):
					__snake_case        =						[0] * 11
					__snake_case        =						[0] * 11

					# mark last 9 numbers
					for _ in range(9		):
										__snake_case        =						1
										__snake_case        =						number // 10
					# flag
					__snake_case        =						True

					# check last 9 numbers for pandigitality

					for x in range(9		):
										if not check_last[x + 1]:
															__snake_case        =						False
					if not f:
										return f

					# mark first 9 numbers
					__snake_case        =						int(str(_UpperCAmelCase		)[:9]		)

					for _ in range(9		):
										__snake_case        =						1
										__snake_case        =						number // 10

					# check first 9 numbers for pandigitality

					for x in range(9		):
										if not check_front[x + 1]:
															__snake_case        =						False
					return f




def    snake_case__						(							lowerCAmelCase :		int		):
					__snake_case        =						[0] * 11

					# mark last 9 numbers
					for _ in range(9		):
										__snake_case        =						1
										__snake_case        =						number // 10
					# flag
					__snake_case        =						True

					# check last 9 numbers for pandigitality

					for x in range(9		):
										if not check_last[x + 1]:
															__snake_case        =						False
					return f




def    snake_case__						(							):
					__snake_case        =						1
					__snake_case        =						1
					__snake_case        =						2
					# temporary Fibonacci numbers

					__snake_case        =						1
					__snake_case        =						1
					__snake_case        =						2
					# temporary Fibonacci numbers mod 1e9

					# mod m=1e9, done for fast optimisation
					__snake_case        =						[0] * 1_000_000
					__snake_case        =						1_000_000_000

					for x in range(1_000_000		):
										__snake_case        =						(aa + ba) % m
										__snake_case        =						ba % m
										__snake_case        =						ca % m
										if checka(_UpperCAmelCase		):
															__snake_case        =						1

					for x in range(1_000_000		):
										__snake_case        =						a + b
										__snake_case        =						b
										__snake_case        =						c
										# perform check only if in tocheck
										if tocheck[x + 3] and check(_UpperCAmelCase		):
															return x + 3  # first 2 already done
					return -1


if __name__ == "__main__":
		print(f'{solution() = }')







import argparse

import torch

from transformers import ImageGPTConfig, ImageGPTForCausalLM, load_tf_weights_in_imagegpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()





def 				A      (	_UpperCAmelCase							:  Tuple				,  _UpperCAmelCase							:  Any				,  _UpperCAmelCase							:  str       )							->					Union[str, Any]:







			'''simple docstring'''
			# Construct configuration depending on size
			_UpperCAmelCase									=  {'small': (512, 8, 24), 'medium': (1_024, 8, 36), 'large': (1_536, 16, 48)}
			_UpperCAmelCase			,	_UpperCAmelCase			,	_UpperCAmelCase									=  MODELS[model_size]  # set model hyperparameters
			_UpperCAmelCase									=  ImageGPTConfig(n_embd=_UpperCAmelCase				,  n_layer=_UpperCAmelCase				,  n_head=_UpperCAmelCase       )
			_UpperCAmelCase									=  ImageGPTForCausalLM(_UpperCAmelCase       )

			# Load weights from numpy
			load_tf_weights_in_imagegpt(_UpperCAmelCase				,  _UpperCAmelCase				,  _UpperCAmelCase       )

			# Save pytorch-model
			_UpperCAmelCase									=  pytorch_dump_folder_path + '/' + WEIGHTS_NAME
			_UpperCAmelCase									=  pytorch_dump_folder_path + '/' + CONFIG_NAME
			print(F"Save PyTorch model to {pytorch_weights_dump_path}"       )
			torch.save(model.state_dict()				,  _UpperCAmelCase       )
			print(F"Save configuration file to {pytorch_config_dump_path}"       )
			with open(_UpperCAmelCase				,  'w'				,  encoding='utf-8'       ) as f:
						f.write(config.to_json_string()       )


if __name__ == "__main__":
							UpperCAmelCase__  =			argparse.ArgumentParser()
							# Required parameters
							parser.add_argument(
							    "--imagegpt_checkpoint_path",
							    default=None,
							    type=str,
							    required=True,
							    help="Path to the TensorFlow checkpoint path.",
							)
							parser.add_argument(
							    "--model_size",
							    default=None,
							    type=str,
							    required=True,
							    help="Size of the model (can be either 'small', 'medium' or 'large').",
							)
							parser.add_argument(
							    "--pytorch_dump_folder_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
							)
							UpperCAmelCase__  =			parser.parse_args()
							convert_imagegpt_checkpoint_to_pytorch(
							    args.imagegpt_checkpoint_path, args.model_size, args.pytorch_dump_folder_path
							)
