





'''simple docstring'''






from heapq import heappop, heappush

import numpy as np







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase    ,	) ->				tuple[float | int, list[tuple[int, int]]]:



			"""simple docstring"""


			__snake_case      ,     __snake_case					:      Tuple							      =     grid.shape
			__snake_case					:      Any							      =     [-1, 1, 0, 0]
			__snake_case					:      int							      =     [0, 0, -1, 1]
			if allow_diagonal:
						dx += [-1, -1, 1, 1]
						dy += [-1, 1, -1, 1]

			__snake_case      ,     __snake_case					:      Tuple							      =     [(0, source)], set()
			__snake_case					:      Tuple							      =     np.full((rows, cols)    ,	np.inf )
			__snake_case					:      Optional[int]							      =     0
			__snake_case					:      List[Any]							      =     np.empty((rows, cols)    ,	dtype=_snake_case )
			__snake_case					:      List[Any]							      =     None

			while queue:
						((__snake_case)      ,     (__snake_case))					:      Union[str, Any]							      =     heappop(_snake_case )
						if (x, y) in visited:
									continue
						visited.add((x, y) )

						if (x, y) == destination:
									__snake_case					:      List[Any]							      =     []
									while (x, y) != source:
												path.append((x, y) )
												__snake_case      ,     __snake_case					:      Dict							      =     predecessors[x, y]
									path.append(_snake_case )  # add the source manually
									path.reverse()
									return matrix[destination], path

						for i in range(len(_snake_case ) ):
									__snake_case      ,     __snake_case					:      Optional[Any]							      =     x + dx[i], y + dy[i]
									if 0 <= nx < rows and 0 <= ny < cols:
												__snake_case					:      Optional[int]							      =     grid[nx][ny]
												if next_node == 1 and matrix[nx, ny] > dist + 1:
															heappush(_snake_case    ,	(dist + 1, (nx, ny)) )
															__snake_case					:      List[Any]							      =     dist + 1
															__snake_case					:      Dict							      =     (x, y)

			return np.inf, []


if __name__ == "__main__":
	import doctest

	doctest.testmod()







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


UpperCAmelCase_		 =					logging.get_logger(__name__)

UpperCAmelCase_		 =					{"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""}


class 	lowerCamelCase__	(       _A):



 """simple docstring"""

 a__					: int =  "openai-gpt"
 a__					: Dict =  {
     "max_position_embeddings": "n_positions",
     "hidden_size": "n_embd",
     "num_attention_heads": "n_head",
     "num_hidden_layers": "n_layer",
 }

 def __init__(    self					:					Union[str, Any]			,						__lowerCAmelCase					:					int=4_04_78			,						__lowerCAmelCase					:					Tuple=5_12			,						__lowerCAmelCase					:					str=7_68			,						__lowerCAmelCase					:					List[Any]=12			,						__lowerCAmelCase					:					Any=12			,						__lowerCAmelCase					:					Dict="gelu"			,						__lowerCAmelCase					:					Union[str, Any]=0.1			,						__lowerCAmelCase					:					Optional[int]=0.1			,						__lowerCAmelCase					:					Any=0.1			,						__lowerCAmelCase					:					List[str]=1E-5			,						__lowerCAmelCase					:					Optional[int]=0.02			,						__lowerCAmelCase					:					Optional[Any]="cls_index"			,						__lowerCAmelCase					:					str=True			,						__lowerCAmelCase					:					int=None			,						__lowerCAmelCase					:					Optional[int]=True			,						__lowerCAmelCase					:					Optional[Any]=0.1			,						**__lowerCAmelCase					:					Tuple			,						)   ->	Optional[Any]:
    _A      =       vocab_size
    _A      =       n_positions
    _A      =       n_embd
    _A      =       n_layer
    _A      =       n_head
    _A      =       afn
    _A      =       resid_pdrop
    _A      =       embd_pdrop
    _A      =       attn_pdrop
    _A      =       layer_norm_epsilon
    _A      =       initializer_range
    _A      =       summary_type
    _A      =       summary_use_proj
    _A      =       summary_activation
    _A      =       summary_first_dropout
    _A      =       summary_proj_to_labels
    super().__init__(**__lowerCAmelCase      )



