
from typing import List, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase__          =		logging.get_logger(__name__)

lowerCamelCase__          =		{
    """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json""",
}







class      A__							(     __magic_name__	):
				lowercase			    =  'autoformer'
				lowercase			    =  {
				    'hidden_size': 'd_model',
				    'num_attention_heads': 'encoder_attention_heads',
				    'num_hidden_layers': 'encoder_layers',
				}






				def __init__(						self					:      Optional[int]    ,     a					:      Optional[int] = None    ,     a					:      Optional[int] = None    ,     a					:      str = "student_t"    ,     a					:      str = "nll"    ,     a					:      int = 1    ,     a					:      List[int] = [1, 2, 3, 4, 5, 6, 7]    ,     a					:      bool = True    ,     a					:      int = 0    ,     a					:      int = 0    ,     a					:      int = 0    ,     a					:      int = 0    ,     a					:      Optional[List[int]] = None    ,     a					:      Optional[List[int]] = None    ,     a					:      int = 64    ,     a					:      int = 2    ,     a					:      int = 2    ,     a					:      int = 2    ,     a					:      int = 2    ,     a					:      int = 32    ,     a					:      int = 32    ,     a					:      str = "gelu"    ,     a					:      float = 0.1    ,     a					:      float = 0.1    ,     a					:      float = 0.1    ,     a					:      float = 0.1    ,     a					:      float = 0.1    ,     a					:      int = 100    ,     a					:      float = 0.0_2    ,     a					:      bool = True    ,     a					:      Union[str, Any]=True    ,     a					:      int = 10    ,     a					:      int = 25    ,     a					:      int = 3    ,     **a					:      Optional[Any]    ,     ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[str]         =		prediction_length
							lowerCAmelCase__      :      Any         =		context_length if context_length is not None else prediction_length
							lowerCAmelCase__      :      List[str]         =		distribution_output
							lowerCAmelCase__      :      int         =		loss
							lowerCAmelCase__      :      Dict         =		input_size
							lowerCAmelCase__      :      Optional[Any]         =		num_time_features
							lowerCAmelCase__      :      str         =		lags_sequence
							lowerCAmelCase__      :      Optional[int]         =		scaling
							lowerCAmelCase__      :      str         =		num_dynamic_real_features
							lowerCAmelCase__      :      List[str]         =		num_static_real_features
							lowerCAmelCase__      :      List[Any]         =		num_static_categorical_features
							if cardinality is not None and num_static_categorical_features > 0:
										if len(a   ) != num_static_categorical_features:
													raise ValueError(
													    'The cardinality should be a list of the same length as `num_static_categorical_features`'   )
										lowerCAmelCase__      :      Optional[int]         =		cardinality
							else:
										lowerCAmelCase__      :      int         =		[0]
							if embedding_dimension is not None and num_static_categorical_features > 0:
										if len(a   ) != num_static_categorical_features:
													raise ValueError(
													    'The embedding dimension should be a list of the same length as `num_static_categorical_features`'   )
										lowerCAmelCase__      :      List[str]         =		embedding_dimension
							else:
										lowerCAmelCase__      :      Tuple         =		[min(50    ,     (cat + 1) // 2   ) for cat in self.cardinality]
							lowerCAmelCase__      :      List[Any]         =		num_parallel_samples

							# Transformer architecture configuration
							lowerCAmelCase__      :      Any         =		input_size * len(self.lags_sequence   ) + self._number_of_features
							lowerCAmelCase__      :      Any         =		d_model
							lowerCAmelCase__      :      int         =		encoder_attention_heads
							lowerCAmelCase__      :      str         =		decoder_attention_heads
							lowerCAmelCase__      :      Dict         =		encoder_ffn_dim
							lowerCAmelCase__      :      Tuple         =		decoder_ffn_dim
							lowerCAmelCase__      :      Optional[Any]         =		encoder_layers
							lowerCAmelCase__      :      Optional[Any]         =		decoder_layers

							lowerCAmelCase__      :      str         =		dropout
							lowerCAmelCase__      :      List[str]         =		attention_dropout
							lowerCAmelCase__      :      Tuple         =		activation_dropout
							lowerCAmelCase__      :      str         =		encoder_layerdrop
							lowerCAmelCase__      :      List[str]         =		decoder_layerdrop

							lowerCAmelCase__      :      List[Any]         =		activation_function
							lowerCAmelCase__      :      Any         =		init_std

							lowerCAmelCase__      :      Dict         =		use_cache

							# Autoformer
							lowerCAmelCase__      :      List[Any]         =		label_length
							lowerCAmelCase__      :      str         =		moving_average
							lowerCAmelCase__      :      Union[str, Any]         =		autocorrelation_factor

							super().__init__(is_encoder_decoder=a    ,     **a   )






				@property
				def 							_lowerCamelCase		(						self					:      Dict   ):






							'''simple docstring'''







							return (
							    sum(self.embedding_dimension   )
							    + self.num_dynamic_real_features
							    + self.num_time_features
							    + self.num_static_real_features
							    + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
							)

from __future__ import annotations

lowerCamelCase__          =		list[list[int]]

# assigning initial values to the grid
lowerCamelCase__          =		[
    [3, 0, 6, 5, 0, 8, 4, 0, 0],
    [5, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

# a grid with no solution
lowerCamelCase__          =		[
    [5, 0, 6, 5, 0, 8, 4, 0, 3],
    [5, 2, 0, 0, 0, 0, 0, 0, 2],
    [1, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_     )				->		bool:
			for i in range(9     ):
						if grid[row][i] == n or grid[i][column] == n:
									return False

			for i in range(3     ):
						for j in range(3     ):
									if grid[(row - row % 3) + i][(column - column % 3) + j] == n:
												return False

			return True
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		tuple[int, int] | None:
			for i in range(9     ):
						for j in range(9     ):
									if grid[i][j] == 0:
												return i, j
			return None
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		Matrix | None:
			if location := find_empty_location(SCREAMING_SNAKE_CASE_     ):
						lowerCAmelCase__      ,				lowerCAmelCase__      :      Any         =		location
			else:
						# If the location is ``None``, then the grid is solved.
						return grid

			for digit in range(1       ,							10     ):
						if is_safe(SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_     ):
									lowerCAmelCase__      :      Optional[Any]         =		digit

									if sudoku(SCREAMING_SNAKE_CASE_     ) is not None:
												return grid

									lowerCAmelCase__      :      List[Any]         =		0

			return None
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		None:
			for row in grid:
						for cell in row:
									print(SCREAMING_SNAKE_CASE_       ,							end=' '     )
						print()


if __name__ == "__main__":
					# make a copy of grid so that you can compare with the unmodified grid
					for example_grid in (initial_grid, no_solution):
										print("""\nExample grid:\n""" + """=""" * 20)
										print_solution(example_grid)
										print("""\nExample grid solution:""")
										lowerCamelCase__          =		sudoku(example_grid)
										if solution is not None:
															print_solution(solution)
										else:
															print("""Cannot find a solution.""")