






"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A		:       int  				=		{
    '''configuration_mobilebert''': [
        '''MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''MobileBertConfig''',
        '''MobileBertOnnxConfig''',
    ],
    '''tokenization_mobilebert''': ['''MobileBertTokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       str  				=		['''MobileBertTokenizerFast''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       List[Any]  				=		[
						    '''MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''MobileBertForMaskedLM''',
						    '''MobileBertForMultipleChoice''',
						    '''MobileBertForNextSentencePrediction''',
						    '''MobileBertForPreTraining''',
						    '''MobileBertForQuestionAnswering''',
						    '''MobileBertForSequenceClassification''',
						    '''MobileBertForTokenClassification''',
						    '''MobileBertLayer''',
						    '''MobileBertModel''',
						    '''MobileBertPreTrainedModel''',
						    '''load_tf_weights_in_mobilebert''',
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       str  				=		[
						    '''TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFMobileBertForMaskedLM''',
						    '''TFMobileBertForMultipleChoice''',
						    '''TFMobileBertForNextSentencePrediction''',
						    '''TFMobileBertForPreTraining''',
						    '''TFMobileBertForQuestionAnswering''',
						    '''TFMobileBertForSequenceClassification''',
						    '''TFMobileBertForTokenClassification''',
						    '''TFMobileBertMainLayer''',
						    '''TFMobileBertModel''',
						    '''TFMobileBertPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_mobilebert import (
						    MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    MobileBertConfig,
						    MobileBertOnnxConfig,
						)
						from .tokenization_mobilebert import MobileBertTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_mobilebert_fast import MobileBertTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_mobilebert import (
												    MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MobileBertForMaskedLM,
												    MobileBertForMultipleChoice,
												    MobileBertForNextSentencePrediction,
												    MobileBertForPreTraining,
												    MobileBertForQuestionAnswering,
												    MobileBertForSequenceClassification,
												    MobileBertForTokenClassification,
												    MobileBertLayer,
												    MobileBertModel,
												    MobileBertPreTrainedModel,
												    load_tf_weights_in_mobilebert,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_mobilebert import (
												    TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFMobileBertForMaskedLM,
												    TFMobileBertForMultipleChoice,
												    TFMobileBertForNextSentencePrediction,
												    TFMobileBertForPreTraining,
												    TFMobileBertForQuestionAnswering,
												    TFMobileBertForSequenceClassification,
												    TFMobileBertForTokenClassification,
												    TFMobileBertMainLayer,
												    TFMobileBertModel,
												    TFMobileBertPreTrainedModel,
												)

else:
						import sys

						__A		:       Tuple  				=		_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)











'''simple docstring'''







from heapq import heappop, heappush

import numpy as np





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase				,			UpperCamelCase				,			UpperCamelCase				,			UpperCamelCase				,			)      ->       tuple[float | int, list[tuple[int, int]]]:
							lowerCamelCase__  ,		lowerCamelCase__					:	Union[str, Any]         =       grid.shape
							lowerCamelCase__					:	List[str]         =       [-1, 1, 0, 0]
							lowerCamelCase__					:	Dict         =       [0, 0, -1, 1]
							if allow_diagonal:
														dx += [-1, -1, 1, 1]
														dy += [-1, 1, -1, 1]

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

							while queue:
														((lowerCamelCase__)  ,		(lowerCamelCase__))					:	List[str]         =       heappop(UpperCamelCase      )
														if (x, y) in visited:
																					continue
														visited.add((x, y)      )

														if (x, y) == destination:
																					lowerCamelCase__					:	Optional[int]         =       []
																					while (x, y) != source:
																												path.append((x, y)      )
																												lowerCamelCase__  ,		lowerCamelCase__					:	List[Any]         =       predecessors[x, y]
																					path.append(UpperCamelCase      )  # add the source manually
																					path.reverse()
																					return matrix[destination], path

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

							return np.inf, []


if __name__ == "__main__":
			import doctest

			doctest.testmod()

