
"""simple docstring"""



from typing import TYPE_CHECKING

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


_snake_case          =						{
    '''configuration_bert''': ['''BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BertConfig''', '''BertOnnxConfig'''],
    '''tokenization_bert''': ['''BasicTokenizer''', '''BertTokenizer''', '''WordpieceTokenizer'''],
}

try:
			if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case          =						['''BertTokenizerFast''']

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case          =						[
			    '''BERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
			    '''BertForMaskedLM''',
			    '''BertForMultipleChoice''',
			    '''BertForNextSentencePrediction''',
			    '''BertForPreTraining''',
			    '''BertForQuestionAnswering''',
			    '''BertForSequenceClassification''',
			    '''BertForTokenClassification''',
			    '''BertLayer''',
			    '''BertLMHeadModel''',
			    '''BertModel''',
			    '''BertPreTrainedModel''',
			    '''load_tf_weights_in_bert''',
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case          =						[
			    '''TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
			    '''TFBertEmbeddings''',
			    '''TFBertForMaskedLM''',
			    '''TFBertForMultipleChoice''',
			    '''TFBertForNextSentencePrediction''',
			    '''TFBertForPreTraining''',
			    '''TFBertForQuestionAnswering''',
			    '''TFBertForSequenceClassification''',
			    '''TFBertForTokenClassification''',
			    '''TFBertLMHeadModel''',
			    '''TFBertMainLayer''',
			    '''TFBertModel''',
			    '''TFBertPreTrainedModel''',
			]
try:
			if not is_tensorflow_text_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case          =						['''TFBertTokenizer''']

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_snake_case          =						[
			    '''FlaxBertForCausalLM''',
			    '''FlaxBertForMaskedLM''',
			    '''FlaxBertForMultipleChoice''',
			    '''FlaxBertForNextSentencePrediction''',
			    '''FlaxBertForPreTraining''',
			    '''FlaxBertForQuestionAnswering''',
			    '''FlaxBertForSequenceClassification''',
			    '''FlaxBertForTokenClassification''',
			    '''FlaxBertModel''',
			    '''FlaxBertPreTrainedModel''',
			]

if TYPE_CHECKING:
			from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig, BertOnnxConfig
			from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_bert_fast import BertTokenizerFast

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_bert import (
						    BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    BertForMaskedLM,
						    BertForMultipleChoice,
						    BertForNextSentencePrediction,
						    BertForPreTraining,
						    BertForQuestionAnswering,
						    BertForSequenceClassification,
						    BertForTokenClassification,
						    BertLayer,
						    BertLMHeadModel,
						    BertModel,
						    BertPreTrainedModel,
						    load_tf_weights_in_bert,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_bert import (
						    TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFBertEmbeddings,
						    TFBertForMaskedLM,
						    TFBertForMultipleChoice,
						    TFBertForNextSentencePrediction,
						    TFBertForPreTraining,
						    TFBertForQuestionAnswering,
						    TFBertForSequenceClassification,
						    TFBertForTokenClassification,
						    TFBertLMHeadModel,
						    TFBertMainLayer,
						    TFBertModel,
						    TFBertPreTrainedModel,
						)

			try:
						if not is_tensorflow_text_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_bert_tf import TFBertTokenizer

			try:
						if not is_flax_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_flax_bert import (
						    FlaxBertForCausalLM,
						    FlaxBertForMaskedLM,
						    FlaxBertForMultipleChoice,
						    FlaxBertForNextSentencePrediction,
						    FlaxBertForPreTraining,
						    FlaxBertForQuestionAnswering,
						    FlaxBertForSequenceClassification,
						    FlaxBertForTokenClassification,
						    FlaxBertModel,
						    FlaxBertPreTrainedModel,
						)

else:
			import sys

			_snake_case          =						_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)








"""simple docstring"""



def 	__snake_case  (    SCREAMING_SNAKE_CASE:					str						):






							"""simple docstring"""



							_lowerCAmelCase  	=			[0 for i in range(len(SCREAMING_SNAKE_CASE						)						)]

							# initialize interval's left pointer and right pointer
							_lowerCAmelCase	,		_lowerCAmelCase  	=			0, 0

							for i in range(1     ,  len(SCREAMING_SNAKE_CASE						)						):
														# case when current index is inside the interval
														if i <= right_pointer:
																					_lowerCAmelCase  	=			min(right_pointer - i + 1     ,  z_result[i - left_pointer]						)
																					_lowerCAmelCase  	=			min_edge

														while go_next(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE						):
																					z_result[i] += 1

														# if new index's result gives us more right interval,
														# we've to update left_pointer and right_pointer
														if i + z_result[i] - 1 > right_pointer:
																					_lowerCAmelCase	,		_lowerCAmelCase  	=			i, i + z_result[i] - 1

							return z_result






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					int     ,  SCREAMING_SNAKE_CASE:					list[int]     ,  SCREAMING_SNAKE_CASE:					str						):






							"""simple docstring"""



							return i + z_result[i] < len(SCREAMING_SNAKE_CASE						) and s[z_result[i]] == s[i + z_result[i]]






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					str     ,  SCREAMING_SNAKE_CASE:					str						):






							"""simple docstring"""



							_lowerCAmelCase  	=			0
							# concatenate 'pattern' and 'input_str' and call z_function
							# with concatenated string
							_lowerCAmelCase  	=			z_function(pattern + input_str						)

							for val in z_result:
														# if value is greater then length of the pattern string
														# that means this index is starting position of substring
														# which is equal to pattern string
														if val >= len(SCREAMING_SNAKE_CASE						):
																					answer += 1

							return answer


if __name__ == "__main__":
	import doctest

	doctest.testmod()






