






"""simple docstring"""



def 						lowercase   (    __snake_case    :			int		, __snake_case    :			int		, __snake_case    :			int		, __snake_case    :			int     ):
		return len_board * len_board_column * row + column



def 						lowercase   (    __snake_case    :			list[list[str]]		, __snake_case    :			str		, __snake_case    :			int		, __snake_case    :			int		, __snake_case    :			int		, __snake_case    :			set[int]		, ):

		if board[row][column] != word[word_index]:
				return False

		if word_index == len(__snake_case     ) - 1:
				return True

		lowercase_			:			str								=       [(0, 1), (0, -1), (-1, 0), (1, 0)]
		lowercase_			:			Optional[Any]								=       len(__snake_case     )
		lowercase_			:			Any								=       len(board[0]     )
		for direction in traverts_directions:
				lowercase_			:			Optional[int]								=       row + direction[0]
				lowercase_			:			Optional[int]								=       column + direction[1]
				if not (0 <= next_i < len_board and 0 <= next_j < len_board_column):
						continue

				lowercase_			:			List[str]								=       get_point_key(__snake_case		, __snake_case		, __snake_case		, __snake_case     )
				if key in visited_points_set:
						continue

				visited_points_set.add(__snake_case     )
				if exits_word(__snake_case		, __snake_case		, __snake_case		, __snake_case		, word_index + 1		, __snake_case     ):
						return True

				visited_points_set.remove(__snake_case     )

		return False



def 						lowercase   (    __snake_case    :			list[list[str]]		, __snake_case    :			str     ):
		lowercase_			:			Tuple								=       (
		    '''The board should be a non empty matrix of single chars strings.'''
		)

		lowercase_			:			Union[str, Any]								=       len(__snake_case     )
		if not isinstance(__snake_case		, __snake_case     ) or len(__snake_case     ) == 0:
				raise ValueError(__snake_case     )

		for row in board:
				if not isinstance(__snake_case		, __snake_case     ) or len(__snake_case     ) == 0:
						raise ValueError(__snake_case     )

				for item in row:
						if not isinstance(__snake_case		, __snake_case     ) or len(__snake_case     ) != 1:
								raise ValueError(__snake_case     )

    # Validate word
		if not isinstance(__snake_case		, __snake_case     ) or len(__snake_case     ) == 0:
				raise ValueError(
				    '''The word parameter should be a string of length greater than 0.'''     )

		lowercase_			:			Dict								=       len(board[0]     )
		for i in range(__snake_case     ):
				for j in range(__snake_case     ):
						if exits_word(
						    __snake_case		, __snake_case		, __snake_case		, __snake_case		, 0		, {get_point_key(__snake_case		, __snake_case		, __snake_case		, __snake_case     )}     ):
								return True

		return False


if __name__ == "__main__":
						import doctest

						doctest.testmod()











"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__A		:	Any      =		{
    '''configuration_markuplm''': ['''MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MarkupLMConfig'''],
    '''feature_extraction_markuplm''': ['''MarkupLMFeatureExtractor'''],
    '''processing_markuplm''': ['''MarkupLMProcessor'''],
    '''tokenization_markuplm''': ['''MarkupLMTokenizer'''],
}

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

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	Optional[int]      =		[
						    '''MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''MarkupLMForQuestionAnswering''',
						    '''MarkupLMForSequenceClassification''',
						    '''MarkupLMForTokenClassification''',
						    '''MarkupLMModel''',
						    '''MarkupLMPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_markuplm import MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP, MarkupLMConfig
						from .feature_extraction_markuplm import MarkupLMFeatureExtractor
						from .processing_markuplm import MarkupLMProcessor
						from .tokenization_markuplm import MarkupLMTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_markuplm_fast import MarkupLMTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_markuplm import (
												    MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MarkupLMForQuestionAnswering,
												    MarkupLMForSequenceClassification,
												    MarkupLMForTokenClassification,
												    MarkupLMModel,
												    MarkupLMPreTrainedModel,
												)


else:
						import sys

						__A		:	Optional[Any]      =		_LazyModule(__name__, globals()['''__file__'''], _import_structure)



