


'''simple docstring'''
from typing import List, Optional

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


__snake_case											=					logging.get_logger(__name__)

__snake_case											=					{
    '''huggingface/autoformer-tourism-monthly''': '''https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json''',
}
class        lowercase     (							snake_case_ ):

		"""simple docstring"""

		_a   			=    'autoformer'
		_a   			=    {
		    'hidden_size': 'd_model',
		    'num_attention_heads': 'encoder_attention_heads',
		    'num_hidden_layers': 'encoder_layers',
		}




		def __init__(		self   ,       UpperCamelCase_ = None   ,       UpperCamelCase_ = None   ,       UpperCamelCase_ = "student_t"   ,       UpperCamelCase_ = "nll"   ,       UpperCamelCase_ = 1   ,       UpperCamelCase_ = [1, 2, 3, 4, 5, 6, 7]   ,       UpperCamelCase_ = True   ,       UpperCamelCase_ = 0   ,       UpperCamelCase_ = 0   ,       UpperCamelCase_ = 0   ,       UpperCamelCase_ = 0   ,       UpperCamelCase_ = None   ,       UpperCamelCase_ = None   ,       UpperCamelCase_ = 64   ,       UpperCamelCase_ = 2   ,       UpperCamelCase_ = 2   ,       UpperCamelCase_ = 2   ,       UpperCamelCase_ = 2   ,       UpperCamelCase_ = 32   ,       UpperCamelCase_ = 32   ,       UpperCamelCase_ = "gelu"   ,       UpperCamelCase_ = 0.1   ,       UpperCamelCase_ = 0.1   ,       UpperCamelCase_ = 0.1   ,       UpperCamelCase_ = 0.1   ,       UpperCamelCase_ = 0.1   ,       UpperCamelCase_ = 100   ,       UpperCamelCase_ = 0.02   ,       UpperCamelCase_ = True   ,       UpperCamelCase_=True   ,       UpperCamelCase_ = 10   ,       UpperCamelCase_ = 25   ,       UpperCamelCase_ = 3   ,       **UpperCamelCase_   ,       ):

							'''simple docstring'''


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

							# Transformer architecture configuration
							UpperCamelCase__       :Dict							 =			input_size * len(self.lags_sequence							) + self._number_of_features
							UpperCamelCase__       :Any							 =			d_model
							UpperCamelCase__       :Dict							 =			encoder_attention_heads
							UpperCamelCase__       :str							 =			decoder_attention_heads
							UpperCamelCase__       :List[Any]							 =			encoder_ffn_dim
							UpperCamelCase__       :str							 =			decoder_ffn_dim
							UpperCamelCase__       :Union[str, Any]							 =			encoder_layers
							UpperCamelCase__       :str							 =			decoder_layers

							UpperCamelCase__       :List[Any]							 =			dropout
							UpperCamelCase__       :str							 =			attention_dropout
							UpperCamelCase__       :Optional[int]							 =			activation_dropout
							UpperCamelCase__       :List[Any]							 =			encoder_layerdrop
							UpperCamelCase__       :List[str]							 =			decoder_layerdrop

							UpperCamelCase__       :Union[str, Any]							 =			activation_function
							UpperCamelCase__       :Union[str, Any]							 =			init_std

							UpperCamelCase__       :int							 =			use_cache

							# Autoformer
							UpperCamelCase__       :str							 =			label_length
							UpperCamelCase__       :Optional[int]							 =			moving_average
							UpperCamelCase__       :Tuple							 =			autocorrelation_factor

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




		@property
		def    lowerCAmelCase__    (		self							):

							'''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
							)



'''simple docstring'''
from __future__ import annotations

__snake_case											=					list[list[int]]

# assigning initial values to the grid
__snake_case											=					[
    [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
__snake_case											=					[
    [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       a				(      __a			, __a			, __a			, __a       )  ->     bool:



					'''simple docstring'''






					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       a				(      __a       )  ->     tuple[int, int] | None:



					'''simple docstring'''






					for i in range(9       ):
										for j in range(9       ):
															if grid[i][j] == 0:
																				return i, j
					return None


def       a				(      __a       )  ->     Matrix | None:



					'''simple docstring'''






					if location := find_empty_location(__a       ):
										UpperCamelCase__ ,    UpperCamelCase__       :Optional[int]							 =			location
					else:
										# If the location is ``None``, then the grid is solved.
										return grid

					for digit in range(1			, 10       ):
										if is_safe(__a			, __a			, __a			, __a       ):
															UpperCamelCase__       :Tuple							 =			digit

															if sudoku(__a       ) is not None:
																				return grid

															UpperCamelCase__       :Union[str, Any]							 =			0

					return None


def       a				(      __a       )  ->     None:



					'''simple docstring'''






					for row in grid:
										for cell in row:
															print(__a			, 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:''')
				__snake_case											=					sudoku(example_grid)
				if solution is not None:
						print_solution(solution)
				else:
						print('''Cannot find a solution.''')