



"""simple docstring"""
from typing import TYPE_CHECKING

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


__a      =				{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__a      =				[
						    "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "MCTCTForCTC",
						    "MCTCTModel",
						    "MCTCTPreTrainedModel",
						]


if TYPE_CHECKING:
						from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
						from .feature_extraction_mctct import MCTCTFeatureExtractor
						from .processing_mctct import MCTCTProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
						import sys

						__a      =				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





"""simple docstring"""
import unittest

import numpy as np

from transformers import BertConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
						from transformers.models.bert.modeling_flax_bert import (
						    FlaxBertForMaskedLM,
						    FlaxBertForMultipleChoice,
						    FlaxBertForNextSentencePrediction,
						    FlaxBertForPreTraining,
						    FlaxBertForQuestionAnswering,
						    FlaxBertForSequenceClassification,
						    FlaxBertForTokenClassification,
						    FlaxBertModel,
						)
class 				lowerCamelCase  (			unittest.TestCase				):






					'''simple docstring'''





					def __init__(       self:							List[Any]						,     snake_case:							List[str]						,     snake_case:							Optional[Any]=13						,     snake_case:							List[str]=7						,     snake_case:							Dict=True						,     snake_case:							List[str]=True						,     snake_case:							Optional[int]=True						,     snake_case:							Any=True						,     snake_case:							Optional[Any]=99						,     snake_case:							Tuple=32						,     snake_case:							Tuple=5						,     snake_case:							Dict=4						,     snake_case:							Optional[Any]=37						,     snake_case:							Union[str, Any]="gelu"						,     snake_case:							Tuple=0.1						,     snake_case:							List[Any]=0.1						,     snake_case:							List[str]=512						,     snake_case:							Optional[int]=16						,     snake_case:							int=2						,     snake_case:							List[Any]=0.0_2						,     snake_case:							Union[str, Any]=4						,     )   ->	List[str]:
											snake_case_ :Dict						=			parent
											snake_case_ :Any						=			batch_size
											snake_case_ :Any						=			seq_length
											snake_case_ :List[str]						=			is_training
											snake_case_ :Optional[Any]						=			use_attention_mask
											snake_case_ :Dict						=			use_token_type_ids
											snake_case_ :Union[str, Any]						=			use_labels
											snake_case_ :str						=			vocab_size
											snake_case_ :int						=			hidden_size
											snake_case_ :List[str]						=			num_hidden_layers
											snake_case_ :Dict						=			num_attention_heads
											snake_case_ :Any						=			intermediate_size
											snake_case_ :Tuple						=			hidden_act
											snake_case_ :int						=			hidden_dropout_prob
											snake_case_ :Optional[Any]						=			attention_probs_dropout_prob
											snake_case_ :Any						=			max_position_embeddings
											snake_case_ :Union[str, Any]						=			type_vocab_size
											snake_case_ :Optional[int]						=			type_sequence_label_size
											snake_case_ :Union[str, Any]						=			initializer_range
											snake_case_ :Tuple						=			num_choices






					def    lowerCAmelCase_				(       self:							Tuple						)   ->	str:
											snake_case_ :Optional[Any]						=			ids_tensor([self.batch_size, self.seq_length]						,     self.vocab_size						)

											snake_case_ :Union[str, Any]						=			None
											if self.use_attention_mask:
																	snake_case_ :str						=			random_attention_mask([self.batch_size, self.seq_length]						)

											snake_case_ :Any						=			None
											if self.use_token_type_ids:
																	snake_case_ :List[str]						=			ids_tensor([self.batch_size, self.seq_length]						,     self.type_vocab_size						)

											snake_case_ :int						=			BertConfig(
											    vocab_size=self.vocab_size						,     hidden_size=self.hidden_size						,     num_hidden_layers=self.num_hidden_layers						,     num_attention_heads=self.num_attention_heads						,     intermediate_size=self.intermediate_size						,     hidden_act=self.hidden_act						,     hidden_dropout_prob=self.hidden_dropout_prob						,     attention_probs_dropout_prob=self.attention_probs_dropout_prob						,     max_position_embeddings=self.max_position_embeddings						,     type_vocab_size=self.type_vocab_size						,     is_decoder=snake_case						,     initializer_range=self.initializer_range						,     )

											return config, input_ids, token_type_ids, attention_mask






					def    lowerCAmelCase_				(       self:							Optional[int]						)   ->	int:
											snake_case_ :str						=			self.prepare_config_and_inputs()
											snake_case_,       snake_case_,       snake_case_,       snake_case_ :Optional[int]						=			config_and_inputs
											snake_case_ :Union[str, Any]						=			{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": attention_mask}
											return config, inputs_dict






					def    lowerCAmelCase_				(       self:							Optional[Any]						)   ->	Any:
											snake_case_ :int						=			self.prepare_config_and_inputs()
											snake_case_,       snake_case_,       snake_case_,       snake_case_ :Dict						=			config_and_inputs

											snake_case_ :Union[str, Any]						=			True
											snake_case_ :Optional[int]						=			floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
											snake_case_ :Tuple						=			ids_tensor([self.batch_size, self.seq_length]						,     vocab_size=2						)

											return (
											    config,
											    input_ids,
											    attention_mask,
											    encoder_hidden_states,
											    encoder_attention_mask,
											)

@require_flax
class 				lowerCamelCase  (			_lowerCAmelCase    ,						unittest.TestCase				):






					'''simple docstring'''





					_A		:			List[str]						=     True

					_A		:			Dict						=     (
					    (
					        FlaxBertModel,
					        FlaxBertForPreTraining,
					        FlaxBertForMaskedLM,
					        FlaxBertForMultipleChoice,
					        FlaxBertForQuestionAnswering,
					        FlaxBertForNextSentencePrediction,
					        FlaxBertForSequenceClassification,
					        FlaxBertForTokenClassification,
					        FlaxBertForQuestionAnswering,
					    )
					    if is_flax_available()
					    else ()
					)






					def    lowerCAmelCase_				(       self:							int						)   ->	List[str]:
											snake_case_ :Any						=			FlaxBertModelTester(self						)






					@slow
					def    lowerCAmelCase_				(       self:							List[str]						)   ->	Dict:
											# Only check this for base model, not necessary for all model classes.
											# This will also help speed-up tests.
											snake_case_ :Dict						=			FlaxBertModel.from_pretrained("""bert-base-cased"""						)
											snake_case_ :Dict						=			model(np.ones((1, 1)						)						)
											self.assertIsNotNone(snake_case						)
