





from typing import TYPE_CHECKING

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


lowercase      :       List[str]									=  {
    """configuration_electra""": ["""ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ElectraConfig""", """ElectraOnnxConfig"""],
    """tokenization_electra""": ["""ElectraTokenizer"""],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase      :       Any									=  ["""ElectraTokenizerFast"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase      :       List[str]									=  [
        """ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """ElectraForCausalLM""",
        """ElectraForMaskedLM""",
        """ElectraForMultipleChoice""",
        """ElectraForPreTraining""",
        """ElectraForQuestionAnswering""",
        """ElectraForSequenceClassification""",
        """ElectraForTokenClassification""",
        """ElectraModel""",
        """ElectraPreTrainedModel""",
        """load_tf_weights_in_electra""",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase      :       Optional[int]									=  [
        """TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """TFElectraForMaskedLM""",
        """TFElectraForMultipleChoice""",
        """TFElectraForPreTraining""",
        """TFElectraForQuestionAnswering""",
        """TFElectraForSequenceClassification""",
        """TFElectraForTokenClassification""",
        """TFElectraModel""",
        """TFElectraPreTrainedModel""",
    ]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    lowercase      :       List[Any]									=  [
        """FlaxElectraForCausalLM""",
        """FlaxElectraForMaskedLM""",
        """FlaxElectraForMultipleChoice""",
        """FlaxElectraForPreTraining""",
        """FlaxElectraForQuestionAnswering""",
        """FlaxElectraForSequenceClassification""",
        """FlaxElectraForTokenClassification""",
        """FlaxElectraModel""",
        """FlaxElectraPreTrainedModel""",
    ]


if TYPE_CHECKING:
    from .configuration_electra import ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, ElectraConfig, ElectraOnnxConfig
    from .tokenization_electra import ElectraTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_electra_fast import ElectraTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_electra import (
            ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
            ElectraForCausalLM,
            ElectraForMaskedLM,
            ElectraForMultipleChoice,
            ElectraForPreTraining,
            ElectraForQuestionAnswering,
            ElectraForSequenceClassification,
            ElectraForTokenClassification,
            ElectraModel,
            ElectraPreTrainedModel,
            load_tf_weights_in_electra,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_electra import (
            TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFElectraForMaskedLM,
            TFElectraForMultipleChoice,
            TFElectraForPreTraining,
            TFElectraForQuestionAnswering,
            TFElectraForSequenceClassification,
            TFElectraForTokenClassification,
            TFElectraModel,
            TFElectraPreTrainedModel,
        )

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_electra import (
            FlaxElectraForCausalLM,
            FlaxElectraForMaskedLM,
            FlaxElectraForMultipleChoice,
            FlaxElectraForPreTraining,
            FlaxElectraForQuestionAnswering,
            FlaxElectraForSequenceClassification,
            FlaxElectraForTokenClassification,
            FlaxElectraModel,
            FlaxElectraPreTrainedModel,
        )

else:
    import sys

    lowercase      :       Union[str, Any]									=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






from __future__ import annotations







def        _lowerCamelCase(	lowercase__   , lowercase__	)						->	bool:

		'''simple docstring'''







		__lowercase=			get_failure_array(lowercase__	)

		# 2) Step through text searching for pattern
		__lowercase,							__lowercase=			0, 0  # index into text, pattern
		while i < len(lowercase__	):
				if pattern[j] == text[i]:
						if j == (len(lowercase__	) - 1):
								return True
						j += 1

				# if this is a prefix in our pattern
				# just go back far enough to continue
				elif j > 0:
						__lowercase=			failure[j - 1]
						continue
				i += 1
		return False







def        _lowerCamelCase(	lowercase__	)						->	list[int]:

		'''simple docstring'''







		__lowercase=			[0]
		__lowercase=			0
		__lowercase=			1
		while j < len(lowercase__	):
				if pattern[i] == pattern[j]:
						i += 1
				elif i > 0:
						__lowercase=			failure[i - 1]
						continue
				j += 1
				failure.append(lowercase__	)
		return failure


if __name__ == "__main__":
	# Test 1)
	lowerCAmelCase           =		'''abc1abc12'''
	lowerCAmelCase           =		'''alskfjaldsabc1abc1abc12k23adsfabcabc'''
	lowerCAmelCase           =		'''alskfjaldsk23adsfabcabc'''
	assert kmp(pattern, texta) and not kmp(pattern, texta)

	# Test 2)
	lowerCAmelCase           =		'''ABABX'''
	lowerCAmelCase           =		'''ABABZABABYABABX'''
	assert kmp(pattern, text)

	# Test 3)
	lowerCAmelCase           =		'''AAAB'''
	lowerCAmelCase           =		'''ABAAAAAB'''
	assert kmp(pattern, text)

	# Test 4)
	lowerCAmelCase           =		'''abcdabcy'''
	lowerCAmelCase           =		'''abcxabcdabxabcdabcdabcy'''
	assert kmp(pattern, text)

	# Test 5)
	lowerCAmelCase           =		'''aabaabaaa'''
	assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]






