




'''simple docstring'''




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


lowercase__  							=					logging.get_logger(__name__)

lowercase__  							=					{
    "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json",
    # See all M-CTC-T models at https://huggingface.co/models?filter=mctct
}






class      UpperCAmelCase_     (  __a     ):


	"""simple docstring"""


	snake_case									=		'''mctct'''







	def __init__(						self						, UpperCAmelCase_=80_65						, UpperCAmelCase_=15_36						, UpperCAmelCase_=36						, UpperCAmelCase_=61_44						, UpperCAmelCase_=4						, UpperCAmelCase_=3_84						, UpperCAmelCase_=9_20						, UpperCAmelCase_=1e-5						, UpperCAmelCase_=0.3						, UpperCAmelCase_="relu"						, UpperCAmelCase_=0.02						, UpperCAmelCase_=0.3						, UpperCAmelCase_=0.3						, UpperCAmelCase_=1						, UpperCAmelCase_=0						, UpperCAmelCase_=2						, UpperCAmelCase_=1						, UpperCAmelCase_=0.3						, UpperCAmelCase_=1						, UpperCAmelCase_=(7,)						, UpperCAmelCase_=(3,)						, UpperCAmelCase_=80						, UpperCAmelCase_=1						, UpperCAmelCase_=None						, UpperCAmelCase_="sum"						, UpperCAmelCase_=False						, **UpperCAmelCase_						, ):
						super().__init__(**__UpperCamelCase						, pad_token_id=__UpperCamelCase						, bos_token_id=__UpperCamelCase						, eos_token_id=__UpperCamelCase				)
						snake_case_	=      vocab_size
						snake_case_	=      hidden_size
						snake_case_	=      num_hidden_layers
						snake_case_	=      intermediate_size
						snake_case_	=      num_attention_heads
						snake_case_	=      attention_head_dim
						snake_case_	=      max_position_embeddings
						snake_case_	=      layer_norm_eps
						snake_case_	=      layerdrop
						snake_case_	=      hidden_act
						snake_case_	=      initializer_range
						snake_case_	=      hidden_dropout_prob
						snake_case_	=      attention_probs_dropout_prob
						snake_case_	=      pad_token_id
						snake_case_	=      bos_token_id
						snake_case_	=      eos_token_id
						snake_case_	=      conv_glu_dim
						snake_case_	=      conv_dropout
						snake_case_	=      num_conv_layers
						snake_case_	=      input_feat_per_channel
						snake_case_	=      input_channels
						snake_case_	=      conv_channels
						snake_case_	=      ctc_loss_reduction
						snake_case_	=      ctc_zero_infinity

						# prevents config testing fail with exporting to json
						snake_case_	=      list(__UpperCamelCase				)
						snake_case_	=      list(__UpperCamelCase				)

						if len(self.conv_kernel				) != self.num_conv_layers:
											raise ValueError(
											    "Configuration for convolutional module is incorrect. "
											    "It is required that `len(config.conv_kernel)` == `config.num_conv_layers` "
											    f'''but is `len(config.conv_kernel) = {len(self.conv_kernel				)}`, '''
											    f'''`config.num_conv_layers = {self.num_conv_layers}`.'''				)






from heapq import heappop, heappush

import numpy as np






def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				np.ndarray		, _SCREAMING_SNAKE_CASE     :				tuple[int, int]		, _SCREAMING_SNAKE_CASE     :				tuple[int, int]		, _SCREAMING_SNAKE_CASE     :				bool		, ):
						UpperCamelCase_,UpperCamelCase_		:							Union[str, Any]  =		grid.shape
						UpperCamelCase_		:							List[str]  =		[-1, 1, 0, 0]
						UpperCamelCase_		:							Dict  =		[0, 0, -1, 1]
						if allow_diagonal:
												dx += [-1, -1, 1, 1]
												dy += [-1, 1, -1, 1]

						UpperCamelCase_,UpperCamelCase_		:							List[Any]  =		[(0, source)], set()
						UpperCamelCase_		:							Any  =		np.full((rows, cols)		, np.inf			)
						UpperCamelCase_		:							List[str]  =		0
						UpperCamelCase_		:							Union[str, Any]  =		np.empty((rows, cols)		, dtype=_SCREAMING_SNAKE_CASE			)
						UpperCamelCase_		:							Optional[int]  =		None

						while queue:
												((UpperCamelCase_),(UpperCamelCase_))		:							Any  =		heappop(_SCREAMING_SNAKE_CASE			)
												if (x, y) in visited:
																		continue
												visited.add((x, y)			)

												if (x, y) == destination:
																		UpperCamelCase_		:							Tuple  =		[]
																		while (x, y) != source:
																								path.append((x, y)			)
																								UpperCamelCase_,UpperCamelCase_		:							Union[str, Any]  =		predecessors[x, y]
																		path.append(_SCREAMING_SNAKE_CASE			)  # add the source manually
																		path.reverse()
																		return matrix[destination], path

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

						return np.inf, []


if __name__ == "__main__":
	import doctest

	doctest.testmod()






