

import unittest

from transformers import ElectraConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
		import torch

		from transformers import (
		    MODEL_FOR_PRETRAINING_MAPPING,
		    ElectraForCausalLM,
		    ElectraForMaskedLM,
		    ElectraForMultipleChoice,
		    ElectraForPreTraining,
		    ElectraForQuestionAnswering,
		    ElectraForSequenceClassification,
		    ElectraForTokenClassification,
		    ElectraModel,
		)
		from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST






class 							A_				:


					def __init__(							self    :	Optional[int]    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	Optional[int]=1_3    ,						UpperCAmelCase    :	Dict=7    ,						UpperCAmelCase    :	Any=True    ,						UpperCAmelCase    :	str=True    ,						UpperCAmelCase    :	Union[str, Any]=True    ,						UpperCAmelCase    :	List[Any]=True    ,						UpperCAmelCase    :	Union[str, Any]=9_9    ,						UpperCAmelCase    :	Optional[int]=3_2    ,						UpperCAmelCase    :	List[str]=5    ,						UpperCAmelCase    :	Any=4    ,						UpperCAmelCase    :	int=3_7    ,						UpperCAmelCase    :	int="gelu"    ,						UpperCAmelCase    :	Union[str, Any]=0.1    ,						UpperCAmelCase    :	Dict=0.1    ,						UpperCAmelCase    :	str=5_1_2    ,						UpperCAmelCase    :	Tuple=1_6    ,						UpperCAmelCase    :	Optional[int]=2    ,						UpperCAmelCase    :	int=0.02    ,						UpperCAmelCase    :	List[str]=3    ,						UpperCAmelCase    :	Any=4    ,						UpperCAmelCase    :	List[Any]=None    ,						)							->			Union[str, Any]:
						__lowerCAmelCase:     List[Any]     			=   parent
						__lowerCAmelCase:     List[Any]     			=   batch_size
						__lowerCAmelCase:     Optional[int]     			=   seq_length
						__lowerCAmelCase:     Union[str, Any]     			=   is_training
						__lowerCAmelCase:     Tuple     			=   use_input_mask
						__lowerCAmelCase:     Any     			=   use_token_type_ids
						__lowerCAmelCase:     List[str]     			=   use_labels
						__lowerCAmelCase:     List[Any]     			=   vocab_size
						__lowerCAmelCase:     Dict     			=   hidden_size
						__lowerCAmelCase:     Optional[Any]     			=   num_hidden_layers
						__lowerCAmelCase:     Dict     			=   num_attention_heads
						__lowerCAmelCase:     int     			=   intermediate_size
						__lowerCAmelCase:     Any     			=   hidden_act
						__lowerCAmelCase:     Optional[Any]     			=   hidden_dropout_prob
						__lowerCAmelCase:     Any     			=   attention_probs_dropout_prob
						__lowerCAmelCase:     Any     			=   max_position_embeddings
						__lowerCAmelCase:     str     			=   type_vocab_size
						__lowerCAmelCase:     Union[str, Any]     			=   type_sequence_label_size
						__lowerCAmelCase:     Tuple     			=   initializer_range
						__lowerCAmelCase:     Any     			=   num_labels
						__lowerCAmelCase:     Optional[int]     			=   num_choices
						__lowerCAmelCase:     Dict     			=   scope


					def 						UpperCAmelCase						(							self    :	List[Any]      )							->			Optional[Any]:
						__lowerCAmelCase:     List[str]     			=   ids_tensor([self.batch_size, self.seq_length]    ,						self.vocab_size      )

						__lowerCAmelCase:     Any     			=   None
						if self.use_input_mask:
							__lowerCAmelCase:     List[Any]     			=   random_attention_mask([self.batch_size, self.seq_length]      )

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

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

						__lowerCAmelCase:     Union[str, Any]     			=   self.get_config()

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


					def 						UpperCAmelCase						(							self    :	str      )							->			int:
						return ElectraConfig(
						    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=UpperCAmelCase    ,						initializer_range=self.initializer_range    ,						)


					def 						UpperCAmelCase						(							self    :	List[str]      )							->			List[str]:
						(
						    __lowerCAmelCase							
						):     str     			=   self.prepare_config_and_inputs()

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

						return (
						    config,
						    input_ids,
						    token_type_ids,
						    input_mask,
						    sequence_labels,
						    token_labels,
						    choice_labels,
						    encoder_hidden_states,
						    encoder_attention_mask,
						)


					def 						UpperCAmelCase						(							self    :	Dict    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	str    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	Any    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	int    ,						)							->			Union[str, Any]:
						__lowerCAmelCase:     Union[str, Any]     			=   ElectraModel(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     int     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase      )
						__lowerCAmelCase:     Tuple     			=   model(UpperCAmelCase    ,						token_type_ids=UpperCAmelCase      )
						__lowerCAmelCase:     Union[str, Any]     			=   model(UpperCAmelCase      )
						self.parent.assertEqual(result.last_hidden_state.shape    ,						(self.batch_size, self.seq_length, self.hidden_size)      )


					def 						UpperCAmelCase						(							self    :	int    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	Union[str, Any]    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	Optional[int]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	List[Any]    ,						)							->			int:
						__lowerCAmelCase:     Optional[int]     			=   True
						__lowerCAmelCase:     Dict     			=   ElectraModel(UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Optional[int]     			=   model(
						    UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						encoder_hidden_states=UpperCAmelCase    ,						encoder_attention_mask=UpperCAmelCase    ,						)
						__lowerCAmelCase:     int     			=   model(
						    UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						encoder_hidden_states=UpperCAmelCase    ,						)
						__lowerCAmelCase:     List[Any]     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase      )
						self.parent.assertEqual(result.last_hidden_state.shape    ,						(self.batch_size, self.seq_length, self.hidden_size)      )


					def 						UpperCAmelCase						(							self    :	Any    ,						UpperCAmelCase    :	Optional[int]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	str    ,						UpperCAmelCase    :	Union[str, Any]    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	int    ,						)							->			Union[str, Any]:
						__lowerCAmelCase:     Optional[int]     			=   ElectraForMaskedLM(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Tuple     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase      )
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length, self.vocab_size)      )


					def 						UpperCAmelCase						(							self    :	Optional[Any]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Optional[int]    ,						UpperCAmelCase    :	str    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Any    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Any    ,						)							->			str:
						__lowerCAmelCase:     Any     			=   ElectraForCausalLM(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Tuple     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase      )
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length, self.vocab_size)      )


					def 						UpperCAmelCase						(							self    :	Union[str, Any]    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	Any    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	Optional[Any]    ,						)							->			Any:
						__lowerCAmelCase:     Optional[int]     			=   self.num_labels
						__lowerCAmelCase:     List[str]     			=   ElectraForTokenClassification(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Optional[Any]     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase      )
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length, self.num_labels)      )


					def 						UpperCAmelCase						(							self    :	int    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	str    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Union[str, Any]    ,						UpperCAmelCase    :	Optional[Any]    ,						)							->			Any:
						__lowerCAmelCase:     Union[str, Any]     			=   self.num_labels
						__lowerCAmelCase:     Optional[int]     			=   ElectraForPreTraining(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     str     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase      )
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length)      )


					def 						UpperCAmelCase						(							self    :	int    ,						UpperCAmelCase    :	Any    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	str    ,						UpperCAmelCase    :	Optional[int]    ,						UpperCAmelCase    :	Union[str, Any]    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	int    ,						)							->			Optional[int]:
						__lowerCAmelCase:     List[str]     			=   self.num_labels
						__lowerCAmelCase:     Tuple     			=   ElectraForSequenceClassification(UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Tuple     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase      )
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.num_labels)      )


					def 						UpperCAmelCase						(							self    :	int    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Tuple    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	List[str]    ,						)							->			Optional[Any]:
						__lowerCAmelCase:     Optional[int]     			=   ElectraForQuestionAnswering(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     List[str]     			=   model(
						    UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						start_positions=UpperCAmelCase    ,						end_positions=UpperCAmelCase    ,						)
						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    :	Optional[int]    ,						UpperCAmelCase    :	Optional[int]    ,						UpperCAmelCase    :	List[Any]    ,						UpperCAmelCase    :	Dict    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	Optional[Any]    ,						UpperCAmelCase    :	Any    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	Dict    ,						)							->			Optional[Any]:
						__lowerCAmelCase:     Optional[Any]     			=   self.num_choices
						__lowerCAmelCase:     Optional[int]     			=   ElectraForMultipleChoice(config=UpperCAmelCase      )
						model.to(UpperCAmelCase      )
						model.eval()
						__lowerCAmelCase:     Optional[int]     			=   input_ids.unsqueeze(1      ).expand(-1    ,						self.num_choices    ,						-1      ).contiguous()
						__lowerCAmelCase:     Optional[int]     			=   token_type_ids.unsqueeze(1      ).expand(-1    ,						self.num_choices    ,						-1      ).contiguous()
						__lowerCAmelCase:     Dict     			=   input_mask.unsqueeze(1      ).expand(-1    ,						self.num_choices    ,						-1      ).contiguous()
						__lowerCAmelCase:     Tuple     			=   model(
						    UpperCAmelCase    ,						attention_mask=UpperCAmelCase    ,						token_type_ids=UpperCAmelCase    ,						labels=UpperCAmelCase    ,						)
						self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.num_choices)      )


					def 						UpperCAmelCase						(							self    :	List[str]      )							->			Any:
						__lowerCAmelCase:     Dict     			=   self.prepare_config_and_inputs()
						(
						    __lowerCAmelCase							
						):     Optional[Any]     			=   config_and_inputs
						__lowerCAmelCase:     List[str]     			=   {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
						return config, inputs_dict







@require_torch
class 							A_				(	snake_case__							,			snake_case__							,			unittest.TestCase      ):
					_lowercase    :  Tuple          =			(
					    (
					        ElectraModel,
					        ElectraForPreTraining,
					        ElectraForMaskedLM,
					        ElectraForCausalLM,
					        ElectraForMultipleChoice,
					        ElectraForTokenClassification,
					        ElectraForSequenceClassification,
					        ElectraForQuestionAnswering,
					    )
					    if is_torch_available()
					    else ()
					)
					_lowercase    :  Optional[Any]          =			(
					    {
					        'feature-extraction': ElectraModel,
					        'fill-mask': ElectraForMaskedLM,
					        'question-answering': ElectraForQuestionAnswering,
					        'text-classification': ElectraForSequenceClassification,
					        'text-generation': ElectraForCausalLM,
					        'token-classification': ElectraForTokenClassification,
					        'zero-shot': ElectraForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)
					_lowercase    :  Dict          =			True


					def 						UpperCAmelCase						(							self    :	str    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	int    ,						UpperCAmelCase    :	Tuple=False      )							->			List[Any]:
						__lowerCAmelCase:     List[Any]     			=   super()._prepare_for_class(UpperCAmelCase    ,						UpperCAmelCase    ,						return_labels=UpperCAmelCase      )

						if return_labels:
							if model_class in get_values(UpperCAmelCase      ):
								__lowerCAmelCase:     Tuple     			=   torch.zeros(
								    (self.model_tester.batch_size, self.model_tester.seq_length)    ,						dtype=torch.long    ,						device=UpperCAmelCase      )
						return inputs_dict


					def 						UpperCAmelCase						(							self    :	List[str]      )							->			Optional[Any]:
						__lowerCAmelCase:     Tuple     			=   ElectraModelTester(self      )
						__lowerCAmelCase:     Optional[Any]     			=   ConfigTester(self    ,						config_class=UpperCAmelCase    ,						hidden_size=3_7      )


					def 						UpperCAmelCase						(							self    :	Tuple      )							->			Optional[Any]:
						self.config_tester.run_common_tests()


					def 						UpperCAmelCase						(							self    :	Union[str, Any]      )							->			List[Any]:
						__lowerCAmelCase:     Any     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_model(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Dict      )							->			Tuple:
						__lowerCAmelCase:     Optional[Any]     			=   self.model_tester.prepare_config_and_inputs_for_decoder()
						self.model_tester.create_and_check_electra_model_as_decoder(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Optional[int]      )							->			Union[str, Any]:
						__lowerCAmelCase:     Any     			=   self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
							__lowerCAmelCase:     List[Any]     			=   type
							self.model_tester.create_and_check_electra_model(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Tuple      )							->			List[str]:
						__lowerCAmelCase:     Dict     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_masked_lm(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Any      )							->			Tuple:
						__lowerCAmelCase:     Optional[int]     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_token_classification(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Tuple      )							->			Tuple:
						__lowerCAmelCase:     Any     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_pretraining(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Optional[int]      )							->			str:
						__lowerCAmelCase:     int     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_sequence_classification(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	str      )							->			Dict:
						__lowerCAmelCase:     str     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_question_answering(*UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	str      )							->			str:
						__lowerCAmelCase:     Optional[int]     			=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_electra_for_multiple_choice(*UpperCAmelCase      )


					@slow
					def 						UpperCAmelCase						(							self    :	Union[str, Any]      )							->			int:
						for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__lowerCAmelCase:     Dict     			=   ElectraModel.from_pretrained(UpperCAmelCase      )
							self.assertIsNotNone(UpperCAmelCase      )


					def 						UpperCAmelCase						(							self    :	Union[str, Any]      )							->			Any:
						__lowerCAmelCase:     int     			=   self.model_tester.prepare_config_and_inputs_for_decoder()
						self.model_tester.create_and_check_electra_for_causal_lm(*UpperCAmelCase      )







@require_torch
class 							A_				(	unittest.TestCase      ):


					@slow
					def 						UpperCAmelCase						(							self    :	Optional[Any]      )							->			Union[str, Any]:
						__lowerCAmelCase:     Tuple     			=   ElectraModel.from_pretrained('google/electra-small-discriminator'      )
						__lowerCAmelCase:     Optional[Any]     			=   torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]      )
						__lowerCAmelCase:     Union[str, Any]     			=   torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]      )
						__lowerCAmelCase:     Optional[int]     			=   model(UpperCAmelCase    ,						attention_mask=UpperCAmelCase      )[0]
						__lowerCAmelCase:     List[Any]     			=   torch.Size((1, 1_1, 2_5_6)      )
						self.assertEqual(output.shape    ,						UpperCAmelCase      )
						__lowerCAmelCase:     Optional[int]     			=   torch.tensor(
						    [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]      )

						self.assertTrue(torch.allclose(output[:, 1:4, 1:4]    ,						UpperCAmelCase    ,						atol=1E-4      )      )








# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

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


_a	 =     {
    '''configuration_tvlt''': ['''TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TvltConfig'''],
    '''feature_extraction_tvlt''': ['''TvltFeatureExtractor'''],
    '''processing_tvlt''': ['''TvltProcessor'''],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     [
      '''TVLT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TvltModel''',
      '''TvltForPreTraining''',
      '''TvltForAudioVisualClassification''',
      '''TvltPreTrainedModel''',
  ]

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     ['''TvltImageProcessor''']


if TYPE_CHECKING:
  from .configuration_tvlt import TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP, TvltConfig
  from .processing_tvlt import TvltProcessor
  from .feature_extraction_tvlt import TvltFeatureExtractor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tvlt import (
        TVLT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TvltForAudioVisualClassification,
        TvltForPreTraining,
        TvltModel,
        TvltPreTrainedModel,
    )

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_tvlt import TvltImageProcessor


else:
  import sys

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





