


'''simple docstring'''



import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          MODEL_FOR_PRETRAINING_MAPPING,
          MegatronBertForCausalLM,
          MegatronBertForMaskedLM,
          MegatronBertForMultipleChoice,
          MegatronBertForNextSentencePrediction,
          MegatronBertForPreTraining,
          MegatronBertForQuestionAnswering,
          MegatronBertForSequenceClassification,
          MegatronBertForTokenClassification,
          MegatronBertModel,
      )





class    UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_=13			,     SCREAMING_SNAKE_CASE_=7			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=99			,     SCREAMING_SNAKE_CASE_=64			,     SCREAMING_SNAKE_CASE_=32			,     SCREAMING_SNAKE_CASE_=5			,     SCREAMING_SNAKE_CASE_=4			,     SCREAMING_SNAKE_CASE_=37			,     SCREAMING_SNAKE_CASE_="gelu"			,     SCREAMING_SNAKE_CASE_=0.1			,     SCREAMING_SNAKE_CASE_=0.1			,     SCREAMING_SNAKE_CASE_=5_12			,     SCREAMING_SNAKE_CASE_=16			,     SCREAMING_SNAKE_CASE_=2			,     SCREAMING_SNAKE_CASE_=0.0_2			,     SCREAMING_SNAKE_CASE_=3			,     SCREAMING_SNAKE_CASE_=4			,     SCREAMING_SNAKE_CASE_=None			,     )				->     Optional[Any]:
         __lowerCamelCase   :	Optional[int]								=		parent
         __lowerCamelCase   :	Any								=		batch_size
         __lowerCamelCase   :	Optional[Any]								=		seq_length
         __lowerCamelCase   :	List[str]								=		is_training
         __lowerCamelCase   :	List[Any]								=		use_input_mask
         __lowerCamelCase   :	List[Any]								=		use_token_type_ids
         __lowerCamelCase   :	Any								=		use_labels
         __lowerCamelCase   :	str								=		vocab_size
         __lowerCamelCase   :	str								=		hidden_size
         __lowerCamelCase   :	List[str]								=		embedding_size
         __lowerCamelCase   :	Union[str, Any]								=		num_hidden_layers
         __lowerCamelCase   :	Dict								=		num_attention_heads
         __lowerCamelCase   :	Dict								=		intermediate_size
         __lowerCamelCase   :	int								=		hidden_act
         __lowerCamelCase   :	Optional[int]								=		hidden_dropout_prob
         __lowerCamelCase   :	Tuple								=		attention_probs_dropout_prob
         __lowerCamelCase   :	List[str]								=		max_position_embeddings
         __lowerCamelCase   :	List[str]								=		type_vocab_size
         __lowerCamelCase   :	List[Any]								=		type_sequence_label_size
         __lowerCamelCase   :	str								=		initializer_range
         __lowerCamelCase   :	List[Any]								=		num_labels
         __lowerCamelCase   :	Tuple								=		num_choices
         __lowerCamelCase   :	Any								=		scope







    def       lowercase_				(							self	)				->     List[str]:
         __lowerCamelCase   :	Any								=		ids_tensor([self.batch_size, self.seq_length]			,     self.vocab_size	)

         __lowerCamelCase   :	Optional[Any]								=		None
         if self.use_input_mask:
              __lowerCamelCase   :	str								=		random_attention_mask([self.batch_size, self.seq_length]	)

         __lowerCamelCase   :	Optional[int]								=		None
         if self.use_token_type_ids:
              __lowerCamelCase   :	Dict								=		ids_tensor([self.batch_size, self.seq_length]			,     self.type_vocab_size	)

         __lowerCamelCase   :	Union[str, Any]								=		None
         __lowerCamelCase   :	Tuple								=		None
         __lowerCamelCase   :	str								=		None
         if self.use_labels:
              __lowerCamelCase   :	Optional[int]								=		ids_tensor([self.batch_size]			,     self.type_sequence_label_size	)
              __lowerCamelCase   :	List[Any]								=		ids_tensor([self.batch_size, self.seq_length]			,     self.num_labels	)
              __lowerCamelCase   :	Optional[int]								=		ids_tensor([self.batch_size]			,     self.num_choices	)

         __lowerCamelCase   :	Dict								=		self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







    def       lowercase_				(							self	)				->     Optional[Any]:
         return MegatronBertConfig(
             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			,     embedding_size=self.embedding_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=SCREAMING_SNAKE_CASE_			,     initializer_range=self.initializer_range			,     )







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     List[str]:
         __lowerCamelCase   :	Union[str, Any]								=		MegatronBertModel(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Union[str, Any]								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Dict								=		model(SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	List[str]								=		model(SCREAMING_SNAKE_CASE_	)

         self.parent.assertEqual(result.last_hidden_state.shape			,     (self.batch_size, self.seq_length, self.hidden_size)	)
         self.parent.assertEqual(result.pooler_output.shape			,     (self.batch_size, self.hidden_size)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Dict:
         __lowerCamelCase   :	List[str]								=		MegatronBertForMaskedLM(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Tuple								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.seq_length, self.vocab_size)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Any:
         __lowerCamelCase   :	List[Any]								=		MegatronBertForCausalLM(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Optional[int]								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.seq_length, self.vocab_size)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     str:
         __lowerCamelCase   :	Dict								=		MegatronBertForNextSentencePrediction(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Optional[Any]								=		model(
             SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_			,     )
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, 2)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     List[Any]:
         __lowerCamelCase   :	int								=		MegatronBertForPreTraining(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	int								=		model(
             SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_			,     next_sentence_label=SCREAMING_SNAKE_CASE_			,     )
         self.parent.assertEqual(result.prediction_logits.shape			,     (self.batch_size, self.seq_length, self.vocab_size)	)
         self.parent.assertEqual(result.seq_relationship_logits.shape			,     (self.batch_size, 2)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Optional[int]:
         __lowerCamelCase   :	List[str]								=		MegatronBertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	int								=		model(
             SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     start_positions=SCREAMING_SNAKE_CASE_			,     end_positions=SCREAMING_SNAKE_CASE_			,     )
         self.parent.assertEqual(result.start_logits.shape			,     (self.batch_size, self.seq_length)	)
         self.parent.assertEqual(result.end_logits.shape			,     (self.batch_size, self.seq_length)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     List[Any]:
         __lowerCamelCase   :	List[str]								=		self.num_labels
         __lowerCamelCase   :	Any								=		MegatronBertForSequenceClassification(SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Optional[int]								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.num_labels)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     int:
         __lowerCamelCase   :	Union[str, Any]								=		self.num_labels
         __lowerCamelCase   :	Optional[int]								=		MegatronBertForTokenClassification(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Dict								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.seq_length, self.num_labels)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Optional[int]:
         __lowerCamelCase   :	Optional[Any]								=		self.num_choices
         __lowerCamelCase   :	str								=		MegatronBertForMultipleChoice(config=SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.eval()
         __lowerCamelCase   :	Dict								=		input_ids.unsqueeze(1	).expand(-1			,     self.num_choices			,     -1	).contiguous()
         __lowerCamelCase   :	Tuple								=		token_type_ids.unsqueeze(1	).expand(-1			,     self.num_choices			,     -1	).contiguous()
         __lowerCamelCase   :	List[Any]								=		input_mask.unsqueeze(1	).expand(-1			,     self.num_choices			,     -1	).contiguous()
         __lowerCamelCase   :	List[Any]								=		model(
             SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_			,     labels=SCREAMING_SNAKE_CASE_			,     )
         self.parent.assertEqual(result.logits.shape			,     (self.batch_size, self.num_choices)	)







    def       lowercase_				(							self	)				->     Tuple:
         __lowerCamelCase   :	int								=		self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       
         )   :	Tuple								=		config_and_inputs
         __lowerCamelCase   :	Dict								=		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
         return config, inputs_dict







@require_torch
class    UpperCAmelCase_  (_UpperCAmelCase					,		_UpperCAmelCase					,		unittest.TestCase  ):





    """simple docstring"""






    lowerCamelCase  :					Dict							     =			(
        (
            MegatronBertModel,
            MegatronBertForMaskedLM,
            MegatronBertForCausalLM,
            MegatronBertForMultipleChoice,
            MegatronBertForNextSentencePrediction,
            MegatronBertForPreTraining,
            MegatronBertForQuestionAnswering,
            MegatronBertForSequenceClassification,
            MegatronBertForTokenClassification,
        )
        if is_torch_available()
        else ()
    )
    lowerCamelCase  :					Union[str, Any]							     =			(
        {
            'feature-extraction': MegatronBertModel,
            'fill-mask': MegatronBertForMaskedLM,
            'question-answering': MegatronBertForQuestionAnswering,
            'text-classification': MegatronBertForSequenceClassification,
            'text-generation': MegatronBertForCausalLM,
            'token-classification': MegatronBertForTokenClassification,
            'zero-shot': MegatronBertForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    lowerCamelCase  :					List[Any]							     =			True
    # test_resize_embeddings = False
    lowerCamelCase  :					List[str]							     =			False







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_=False	)				->     Union[str, Any]:
         __lowerCamelCase   :	Union[str, Any]								=		super()._prepare_for_class(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     return_labels=SCREAMING_SNAKE_CASE_	)

         if return_labels:
              if model_class in get_values(SCREAMING_SNAKE_CASE_	):
                   __lowerCamelCase   :	Union[str, Any]								=		torch.zeros(
                       (self.model_tester.batch_size, self.model_tester.seq_length)			,     dtype=torch.long			,     device=SCREAMING_SNAKE_CASE_	)
                   __lowerCamelCase   :	Optional[int]								=		torch.zeros(
                       self.model_tester.batch_size			,     dtype=torch.long			,     device=SCREAMING_SNAKE_CASE_	)
         return inputs_dict







    def       lowercase_				(							self	)				->     Union[str, Any]:
         __lowerCamelCase   :	Union[str, Any]								=		MegatronBertModelTester(self	)
         __lowerCamelCase   :	Union[str, Any]								=		ConfigTester(self			,     config_class=SCREAMING_SNAKE_CASE_			,     hidden_size=37	)







    def       lowercase_				(							self	)				->     Any:
         self.config_tester.run_common_tests()







    def       lowercase_				(							self	)				->     Dict:
         __lowerCamelCase   :	Optional[Any]								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_model(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     Optional[Any]:
         __lowerCamelCase   :	Tuple								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_masked_lm(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     List[str]:
         __lowerCamelCase   :	Optional[int]								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     int:
         __lowerCamelCase   :	Dict								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     Optional[Any]:
         __lowerCamelCase   :	Any								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_pretraining(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     Union[str, Any]:
         __lowerCamelCase   :	Dict								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_question_answering(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     str:
         __lowerCamelCase   :	Dict								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     List[str]:
         __lowerCamelCase   :	Any								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_megatron_bert_for_token_classification(*SCREAMING_SNAKE_CASE_	)







def 			UpperCAmelCase__					(	UpperCAmelCase_    :				Optional[int]							)     ->		Any:
     return torch.tensor(
         UpperCAmelCase_      ,    dtype=torch.long      ,    device=UpperCAmelCase_      ,    )


A__		:					Optional[int]												=  1e-4





@require_torch
@require_sentencepiece
@require_tokenizers
class    UpperCAmelCase_  (unittest.TestCase  ):





    """simple docstring"""






    @slow
    @unittest.skip('Model is not available.'	)
    def       lowercase_				(							self	)				->     str:
         __lowerCamelCase   :	Optional[int]								=		'nvidia/megatron-bert-uncased-345m'
         if "MYDIR" in os.environ:
              __lowerCamelCase   :	str								=		os.path.join(os.environ['MYDIR']			,     SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Optional[int]								=		MegatronBertModel.from_pretrained(SCREAMING_SNAKE_CASE_	)
         model.to(SCREAMING_SNAKE_CASE_	)
         model.half()
         __lowerCamelCase   :	Optional[Any]								=		_long_tensor([[1_01, 71_10, 10_05, 10_56, 20_23, 1_13_33, 1_74_13, 10_29, 1_02]]	)
         with torch.no_grad():
              __lowerCamelCase   :	List[str]								=		model(SCREAMING_SNAKE_CASE_	)[0]
         __lowerCamelCase   :	int								=		torch.Size((1, 9, 10_24)	)
         self.assertEqual(output.shape			,     SCREAMING_SNAKE_CASE_	)

         __lowerCamelCase   :	str								=		[-0.6_0_4_0, -0.2_5_1_7, -0.1_0_2_5, 0.3_4_2_0, -0.6_7_5_8, -0.0_0_1_7, -0.1_0_8_9, -0.1_9_9_0, 0.5_7_2_8]
         for ii in range(3	):
              for jj in range(3	):
                   __lowerCamelCase   :	Union[str, Any]								=		output[0, ii, jj]
                   __lowerCamelCase   :	Union[str, Any]								=		expected[3 * ii + jj]
                   __lowerCamelCase   :	Optional[Any]								=		'ii={} jj={} a={} b={}'.format(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
                   self.assertTrue(math.isclose(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     rel_tol=SCREAMING_SNAKE_CASE_			,     abs_tol=SCREAMING_SNAKE_CASE_	)			,     msg=SCREAMING_SNAKE_CASE_	)










'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_torch_available,
    is_vision_available,
)


A__		:					List[str]												=  {"""configuration_beit""": ["""BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BeitConfig""", """BeitOnnxConfig"""]}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A__		:					str												=  ["""BeitFeatureExtractor"""]
      A__		:					List[str]												=  ["""BeitImageProcessor"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A__		:					Optional[int]												=  [
          """BEIT_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """BeitForImageClassification""",
          """BeitForMaskedImageModeling""",
          """BeitForSemanticSegmentation""",
          """BeitModel""",
          """BeitPreTrainedModel""",
      ]


try:
      if not is_flax_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      A__		:					Any												=  [
          """FlaxBeitForImageClassification""",
          """FlaxBeitForMaskedImageModeling""",
          """FlaxBeitModel""",
          """FlaxBeitPreTrainedModel""",
      ]

if TYPE_CHECKING:
      from .configuration_beit import BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, BeitConfig, BeitOnnxConfig

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_beit import BeitFeatureExtractor
            from .image_processing_beit import BeitImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_beit import (
                BEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
                BeitForImageClassification,
                BeitForMaskedImageModeling,
                BeitForSemanticSegmentation,
                BeitModel,
                BeitPreTrainedModel,
            )

      try:
            if not is_flax_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_flax_beit import (
                FlaxBeitForImageClassification,
                FlaxBeitForMaskedImageModeling,
                FlaxBeitModel,
                FlaxBeitPreTrainedModel,
            )


else:
      import sys

      A__		:					Optional[Any]												=  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






