import unittest

from transformers import FunnelConfig, FunnelTokenizer, 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
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import (
         MODEL_FOR_PRETRAINING_MAPPING,
         FunnelBaseModel,
         FunnelForMaskedLM,
         FunnelForMultipleChoice,
         FunnelForPreTraining,
         FunnelForQuestionAnswering,
         FunnelForSequenceClassification,
         FunnelForTokenClassification,
         FunnelModel,
     )



class 			UpperCamelCase					:

     '''simple docstring'''

     def __init__(       self					,					A_					,					A_=13					,					A_=7					,					A_=True					,					A_=True					,					A_=True					,					A_=True					,					A_=99					,					A_=[1, 1, 2]					,					A_=1					,					A_=32					,					A_=4					,					A_=8					,					A_=37					,					A_="gelu_new"					,					A_=0.1					,					A_=0.1					,					A_=0.0					,					A_=5_12					,					A_=3					,					A_=0.02					,					A_=3					,					A_=4					,					A_=None					,					A_=False					,					)			->					Any:






           """simple docstring"""
           _lowerCamelCase           =					parent
           _lowerCamelCase           =					batch_size
           _lowerCamelCase           =					seq_length
           _lowerCamelCase           =					is_training
           _lowerCamelCase           =					use_input_mask
           _lowerCamelCase           =					use_token_type_ids
           _lowerCamelCase           =					use_labels
           _lowerCamelCase           =					vocab_size
           _lowerCamelCase           =					block_sizes
           _lowerCamelCase           =					num_decoder_layers
           _lowerCamelCase           =					d_model
           _lowerCamelCase           =					n_head
           _lowerCamelCase           =					d_head
           _lowerCamelCase           =					d_inner
           _lowerCamelCase           =					hidden_act
           _lowerCamelCase           =					hidden_dropout
           _lowerCamelCase           =					attention_dropout
           _lowerCamelCase           =					activation_dropout
           _lowerCamelCase           =					max_position_embeddings
           _lowerCamelCase           =					type_vocab_size
           _lowerCamelCase           =					2
           _lowerCamelCase           =					num_labels
           _lowerCamelCase           =					num_choices
           _lowerCamelCase           =					scope
           _lowerCamelCase           =					initializer_std

           # Used in the tests to check the size of the first attention layer
           _lowerCamelCase           =					n_head
           # Used in the tests to check the size of the first hidden state
           _lowerCamelCase           =					self.d_model
           # Used in the tests to check the number of output hidden states/attentions
           _lowerCamelCase           =					sum(self.block_sizes    ) + (0 if base else self.num_decoder_layers)
           # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
           # the last hidden state of the first block (which is the first hidden state of the decoder).
           if not base:
                 _lowerCamelCase           =					self.num_hidden_layers + 2



     def 		UpperCamelCase_    (       self    )			->					str:






           """simple docstring"""
           _lowerCamelCase           =					ids_tensor([self.batch_size, self.seq_length]					,					self.vocab_size    )

           _lowerCamelCase           =					None
           if self.use_input_mask:
                 _lowerCamelCase           =					ids_tensor([self.batch_size, self.seq_length]					,					vocab_size=2    )

           _lowerCamelCase           =					None
           if self.use_token_type_ids:
                 _lowerCamelCase           =					ids_tensor([self.batch_size, self.seq_length]					,					self.type_vocab_size    )

           _lowerCamelCase           =					None
           _lowerCamelCase           =					None
           _lowerCamelCase           =					None
           if self.use_labels:
                 _lowerCamelCase           =					ids_tensor([self.batch_size]					,					self.type_sequence_label_size    )
                 _lowerCamelCase           =					ids_tensor([self.batch_size, self.seq_length]					,					self.num_labels    )
                 _lowerCamelCase           =					ids_tensor([self.batch_size]					,					self.num_choices    )
                 _lowerCamelCase           =					ids_tensor([self.batch_size, self.seq_length]					,					1    )

           _lowerCamelCase           =					self.get_config()

           return (
               config,
               input_ids,
               token_type_ids,
               input_mask,
               sequence_labels,
               token_labels,
               choice_labels,
               fake_token_labels,
           )



     def 		UpperCamelCase_    (       self    )			->					Union[str, Any]:






           """simple docstring"""
           return FunnelConfig(
               vocab_size=self.vocab_size					,					block_sizes=self.block_sizes					,					num_decoder_layers=self.num_decoder_layers					,					d_model=self.d_model					,					n_head=self.n_head					,					d_head=self.d_head					,					d_inner=self.d_inner					,					hidden_act=self.hidden_act					,					hidden_dropout=self.hidden_dropout					,					attention_dropout=self.attention_dropout					,					activation_dropout=self.activation_dropout					,					max_position_embeddings=self.max_position_embeddings					,					type_vocab_size=self.type_vocab_size					,					initializer_std=self.initializer_std					,					)



     def 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					Union[str, Any]:






           """simple docstring"""
           _lowerCamelCase           =					FunnelModel(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					attention_mask=__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, self.seq_length, self.d_model)    )

           _lowerCamelCase           =					False
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, self.seq_length, self.d_model)    )

           _lowerCamelCase           =					False
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, self.seq_length, self.d_model)    )



     def 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					int:






           """simple docstring"""
           _lowerCamelCase           =					FunnelBaseModel(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					attention_mask=__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, 2, self.d_model)    )

           _lowerCamelCase           =					False
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, 3, self.d_model)    )

           _lowerCamelCase           =					False
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE    )
           self.parent.assertEqual(result.last_hidden_state.shape					,					(self.batch_size, 2, self.d_model)    )



     def 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					List[str]:






           """simple docstring"""
           _lowerCamelCase           =					self.num_labels
           _lowerCamelCase           =					FunnelForPreTraining(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					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)    )



     def 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					List[Any]:






           """simple docstring"""
           _lowerCamelCase           =					FunnelForMaskedLM(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					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 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					str:






           """simple docstring"""
           _lowerCamelCase           =					self.num_labels
           _lowerCamelCase           =					FunnelForSequenceClassification(__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					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 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					str:






           """simple docstring"""
           _lowerCamelCase           =					self.num_choices
           _lowerCamelCase           =					FunnelForMultipleChoice(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					input_ids.unsqueeze(1    ).expand(-1					,					self.num_choices					,					-1    ).contiguous()
           _lowerCamelCase           =					token_type_ids.unsqueeze(1    ).expand(-1					,					self.num_choices					,					-1    ).contiguous()
           _lowerCamelCase           =					input_mask.unsqueeze(1    ).expand(-1					,					self.num_choices					,					-1    ).contiguous()
           _lowerCamelCase           =					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 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					List[str]:






           """simple docstring"""
           _lowerCamelCase           =					self.num_labels
           _lowerCamelCase           =					FunnelForTokenClassification(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					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 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					A_					,					)			->					Dict:






           """simple docstring"""
           _lowerCamelCase           =					FunnelForQuestionAnswering(config=__SCREAMING_SNAKE_CASE    )
           model.to(__SCREAMING_SNAKE_CASE    )
           model.eval()
           _lowerCamelCase           =					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 		UpperCamelCase_    (       self    )			->					int:






           """simple docstring"""
           _lowerCamelCase           =					self.prepare_config_and_inputs()
           (
               (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,       (
               _lowerCamelCase       
           )     ,              
           )           =					config_and_inputs
           _lowerCamelCase           =					{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
           return config, inputs_dict





@require_torch
class 			UpperCamelCase					(			_A ,	_A ,	unittest.TestCase			):

     '''simple docstring'''

     A_					    =	False
     A_					    =	False
     A_					    =	(
         (
             FunnelModel,
             FunnelForMaskedLM,
             FunnelForPreTraining,
             FunnelForQuestionAnswering,
             FunnelForTokenClassification,
         )
         if is_torch_available()
         else ()
     )
     A_					    =	(
         {
             'feature-extraction': (FunnelBaseModel, FunnelModel),
             'fill-mask': FunnelForMaskedLM,
             'question-answering': FunnelForQuestionAnswering,
             'text-classification': FunnelForSequenceClassification,
             'token-classification': FunnelForTokenClassification,
             'zero-shot': FunnelForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )



     def 		UpperCamelCase_    (       self					,					A_					,					A_					,					A_=False    )			->					Optional[int]:






           """simple docstring"""
           _lowerCamelCase           =					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           =					torch.zeros(
                           (self.model_tester.batch_size, self.model_tester.seq_length)					,					dtype=torch.long					,					device=__SCREAMING_SNAKE_CASE    )
           return inputs_dict



     def 		UpperCamelCase_    (       self    )			->					Any:






           """simple docstring"""
           _lowerCamelCase           =					FunnelModelTester(self    )
           _lowerCamelCase           =					ConfigTester(self					,					config_class=__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Dict:






           """simple docstring"""
           self.config_tester.run_common_tests()



     def 		UpperCamelCase_    (       self    )			->					str:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Optional[Any]:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_pretraining(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					str:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_masked_lm(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Union[str, Any]:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_token_classification(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					int:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*__SCREAMING_SNAKE_CASE    )





     def 		UpperCamelCase_    (       self					,					A_    )			->					Tuple:






           """simple docstring"""
           if hasattr(__SCREAMING_SNAKE_CASE					,					'''weight'''    ) and module.weight is not None:
                 module.weight.data.fill_(3    )
           if hasattr(__SCREAMING_SNAKE_CASE					,					'''bias'''    ) and module.bias is not None:
                 module.bias.data.fill_(3    )

           for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
                 if hasattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    ) and getattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    ) is not None:
                       _lowerCamelCase           =					getattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    )
                       weight.data.fill_(3    )





@require_torch
class 			UpperCamelCase					(			_A ,	unittest.TestCase			):

     '''simple docstring'''

     A_					    =	False
     A_					    =	False
     A_					    =	(
         (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
     )



     def 		UpperCamelCase_    (       self    )			->					Optional[Any]:






           """simple docstring"""
           _lowerCamelCase           =					FunnelModelTester(self					,					base=__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					ConfigTester(self					,					config_class=__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					List[Any]:






           """simple docstring"""
           self.config_tester.run_common_tests()



     def 		UpperCamelCase_    (       self    )			->					Dict:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_base_model(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Any:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_sequence_classification(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Optional[int]:






           """simple docstring"""
           _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_multiple_choice(*__SCREAMING_SNAKE_CASE    )



     def 		UpperCamelCase_    (       self    )			->					Union[str, Any]:






           """simple docstring"""
           _lowerCamelCase     ,       _lowerCamelCase           =					self.model_tester.prepare_config_and_inputs_for_common()
           _lowerCamelCase           =					True

           for model_class in self.all_model_classes:
                 if model_class.__name__ == "FunnelBaseModel":
                       continue
                 _lowerCamelCase           =					model_class(__SCREAMING_SNAKE_CASE    )
                 model.to(__SCREAMING_SNAKE_CASE    )
                 model.train()
                 _lowerCamelCase           =					self._prepare_for_class(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE					,					return_labels=__SCREAMING_SNAKE_CASE    )
                 _lowerCamelCase           =					model(**__SCREAMING_SNAKE_CASE    ).loss
                 loss.backward()





     def 		UpperCamelCase_    (       self					,					A_    )			->					Optional[Any]:






           """simple docstring"""
           if hasattr(__SCREAMING_SNAKE_CASE					,					'''weight'''    ) and module.weight is not None:
                 module.weight.data.fill_(3    )
           if hasattr(__SCREAMING_SNAKE_CASE					,					'''bias'''    ) and module.bias is not None:
                 module.bias.data.fill_(3    )

           for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
                 if hasattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    ) and getattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    ) is not None:
                       _lowerCamelCase           =					getattr(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    )
                       weight.data.fill_(3    )





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

     '''simple docstring'''

     def 		UpperCamelCase_    (       self    )			->					Tuple:






           """simple docstring"""
           _lowerCamelCase           =					13
           _lowerCamelCase           =					7
           _lowerCamelCase           =					torch.arange(0					,					batch_size * sequence_length    ).long().reshape(__SCREAMING_SNAKE_CASE					,					__SCREAMING_SNAKE_CASE    )
           _lowerCamelCase           =					[0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
           _lowerCamelCase           =					torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]    )

           _lowerCamelCase           =					FunnelModel.from_pretrained('''sgugger/funnel-random-tiny'''    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )[0].abs()

           _lowerCamelCase           =					torch.tensor(23_44.83_52    )
           _lowerCamelCase           =					torch.tensor(0.8052    )
           self.assertTrue(torch.allclose(output.sum()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )
           self.assertTrue(torch.allclose(output.mean()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )

           _lowerCamelCase           =					torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]    )
           _lowerCamelCase           =					model(__SCREAMING_SNAKE_CASE					,					attention_mask=__SCREAMING_SNAKE_CASE					,					token_type_ids=__SCREAMING_SNAKE_CASE    )[0].abs()

           _lowerCamelCase           =					torch.tensor(23_43.84_25    )
           _lowerCamelCase           =					torch.tensor(0.8049    )
           self.assertTrue(torch.allclose(output.sum()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )
           self.assertTrue(torch.allclose(output.mean()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )





     @slow
     def 		UpperCamelCase_    (       self    )			->					str:






           """simple docstring"""
           _lowerCamelCase           =					FunnelTokenizer.from_pretrained('''huggingface/funnel-small'''    )
           _lowerCamelCase           =					FunnelModel.from_pretrained('''huggingface/funnel-small'''    )
           _lowerCamelCase           =					tokenizer('''Hello! I am the Funnel Transformer model.'''					,					return_tensors='''pt'''    )
           _lowerCamelCase           =					model(**__SCREAMING_SNAKE_CASE    )[0]

           _lowerCamelCase           =					torch.tensor(2_35.72_46    )
           _lowerCamelCase           =					torch.tensor(0.0256    )
           self.assertTrue(torch.allclose(output.sum()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )
           self.assertTrue(torch.allclose(output.mean()					,					__SCREAMING_SNAKE_CASE					,					atol=1E-4    )    )


"""simple docstring"""




from typing import TYPE_CHECKING

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


__A	:       Dict        =						{'configuration_cvt': ['CVT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CvtConfig']}


try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__A	:       Any        =						[
	    'CVT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'CvtForImageClassification',
	    'CvtModel',
	    'CvtPreTrainedModel',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__A	:       List[str]        =						[
	    'TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'TFCvtForImageClassification',
	    'TFCvtModel',
	    'TFCvtPreTrainedModel',
	]

if TYPE_CHECKING:
	from .configuration_cvt import CVT_PRETRAINED_CONFIG_ARCHIVE_MAP, CvtConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_cvt import (
		    CVT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    CvtForImageClassification,
		    CvtModel,
		    CvtPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_cvt import (
		    TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFCvtForImageClassification,
		    TFCvtModel,
		    TFCvtPreTrainedModel,
		)


else:
	import sys

	__A	:       str        =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





