





"""simple docstring"""
import collections
import inspect
import unittest

from transformers import SwinvaConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
  import torch
  from torch import nn

  from transformers import SwinvaForImageClassification, SwinvaForMaskedImageModeling, SwinvaModel
  from transformers.models.swinva.modeling_swinva import SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor






class    _SCREAMING_SNAKE_CASE:




       def __init__(		self						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__=13						,SCREAMING_SNAKE_CASE__=32						,SCREAMING_SNAKE_CASE__=2						,SCREAMING_SNAKE_CASE__=3						,SCREAMING_SNAKE_CASE__=16						,SCREAMING_SNAKE_CASE__=[1, 2, 1]						,SCREAMING_SNAKE_CASE__=[2, 2, 4]						,SCREAMING_SNAKE_CASE__=2						,SCREAMING_SNAKE_CASE__=2.0						,SCREAMING_SNAKE_CASE__=True						,SCREAMING_SNAKE_CASE__=0.0						,SCREAMING_SNAKE_CASE__=0.0						,SCREAMING_SNAKE_CASE__=0.1						,SCREAMING_SNAKE_CASE__="gelu"						,SCREAMING_SNAKE_CASE__=False						,SCREAMING_SNAKE_CASE__=True						,SCREAMING_SNAKE_CASE__=0.0_2						,SCREAMING_SNAKE_CASE__=1E-5						,SCREAMING_SNAKE_CASE__=True						,SCREAMING_SNAKE_CASE__=None						,SCREAMING_SNAKE_CASE__=True						,SCREAMING_SNAKE_CASE__=10						,SCREAMING_SNAKE_CASE__=8						,)     -> str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :List[str]													=    parent
             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    batch_size
             __SCREAMING_SNAKE_CASE  :str													=    image_size
             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    patch_size
             __SCREAMING_SNAKE_CASE  :str													=    num_channels
             __SCREAMING_SNAKE_CASE  :int													=    embed_dim
             __SCREAMING_SNAKE_CASE  :List[str]													=    depths
             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    num_heads
             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    window_size
             __SCREAMING_SNAKE_CASE  :Any													=    mlp_ratio
             __SCREAMING_SNAKE_CASE  :Optional[int]													=    qkv_bias
             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    hidden_dropout_prob
             __SCREAMING_SNAKE_CASE  :Optional[int]													=    attention_probs_dropout_prob
             __SCREAMING_SNAKE_CASE  :List[Any]													=    drop_path_rate
             __SCREAMING_SNAKE_CASE  :int													=    hidden_act
             __SCREAMING_SNAKE_CASE  :List[str]													=    use_absolute_embeddings
             __SCREAMING_SNAKE_CASE  :str													=    patch_norm
             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    layer_norm_eps
             __SCREAMING_SNAKE_CASE  :Tuple													=    initializer_range
             __SCREAMING_SNAKE_CASE  :Dict													=    is_training
             __SCREAMING_SNAKE_CASE  :List[str]													=    scope
             __SCREAMING_SNAKE_CASE  :Any													=    use_labels
             __SCREAMING_SNAKE_CASE  :str													=    type_sequence_label_size
             __SCREAMING_SNAKE_CASE  :Dict													=    encoder_stride




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

             __SCREAMING_SNAKE_CASE  :Dict													=    None
             if self.use_labels:
                   __SCREAMING_SNAKE_CASE  :Tuple													=    ids_tensor([self.batch_size]						,self.type_sequence_label_size				)

             __SCREAMING_SNAKE_CASE  :Optional[int]													=    self.get_config()

             return config, pixel_values, labels




       def        _UpperCamelCase	(		self				)     -> int:





             """simple docstring"""






             return SwinvaConfig(
                 image_size=self.image_size						,patch_size=self.patch_size						,num_channels=self.num_channels						,embed_dim=self.embed_dim						,depths=self.depths						,num_heads=self.num_heads						,window_size=self.window_size						,mlp_ratio=self.mlp_ratio						,qkv_bias=self.qkv_bias						,hidden_dropout_prob=self.hidden_dropout_prob						,attention_probs_dropout_prob=self.attention_probs_dropout_prob						,drop_path_rate=self.drop_path_rate						,hidden_act=self.hidden_act						,use_absolute_embeddings=self.use_absolute_embeddings						,path_norm=self.patch_norm						,layer_norm_eps=self.layer_norm_eps						,initializer_range=self.initializer_range						,encoder_stride=self.encoder_stride						,)




       def        _UpperCamelCase	(		self						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__				)     -> str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :List[str]													=    SwinvaModel(config=a_				)
             model.to(a_				)
             model.eval()
             __SCREAMING_SNAKE_CASE  :str													=    model(a_				)

             __SCREAMING_SNAKE_CASE  :Optional[int]													=    ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths				) - 1))
             __SCREAMING_SNAKE_CASE  :str													=    int(config.embed_dim * 2 ** (len(config.depths				) - 1)				)

             self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, expected_seq_len, expected_dim)				)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Tuple													=    SwinvaForMaskedImageModeling(config=a_				)
             model.to(a_				)
             model.eval()
             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    model(a_				)
             self.parent.assertEqual(
                 result.logits.shape						,(self.batch_size, self.num_channels, self.image_size, self.image_size)				)

             # test greyscale images
             __SCREAMING_SNAKE_CASE  :Tuple													=    1
             __SCREAMING_SNAKE_CASE  :Any													=    SwinvaForMaskedImageModeling(a_				)
             model.to(a_				)
             model.eval()

             __SCREAMING_SNAKE_CASE  :Any													=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
             __SCREAMING_SNAKE_CASE  :List[Any]													=    model(a_				)
             self.parent.assertEqual(result.logits.shape						,(self.batch_size, 1, self.image_size, self.image_size)				)




       def        _UpperCamelCase	(		self						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__				)     -> Optional[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    self.type_sequence_label_size
             __SCREAMING_SNAKE_CASE  :Dict													=    SwinvaForImageClassification(a_				)
             model.to(a_				)
             model.eval()
             __SCREAMING_SNAKE_CASE  :int													=    model(a_						,labels=a_				)
             self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.type_sequence_label_size)				)




       def        _UpperCamelCase	(		self				)     -> Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Optional[int]													=    self.prepare_config_and_inputs()
             __SCREAMING_SNAKE_CASE  :Dict													=    config_and_inputs
             __SCREAMING_SNAKE_CASE  :List[str]													=    {"pixel_values": pixel_values}
             return config, inputs_dict






@require_torch
class    _SCREAMING_SNAKE_CASE(  A       ,      A       ,      unittest.TestCase    ):
       SCREAMING_SNAKE_CASE_  : Optional[Any]      		=    (
           (SwinvaModel, SwinvaForImageClassification, SwinvaForMaskedImageModeling) if is_torch_available() else ()
       )
       SCREAMING_SNAKE_CASE_  : Optional[Any]      		=    (
           {'''feature-extraction''': SwinvaModel, '''image-classification''': SwinvaForImageClassification}
           if is_torch_available()
           else {}
       )

       SCREAMING_SNAKE_CASE_  : int      		=    False
       SCREAMING_SNAKE_CASE_  : Tuple      		=    False
       SCREAMING_SNAKE_CASE_  : List[str]      		=    False
       SCREAMING_SNAKE_CASE_  : int      		=    False




       def        _UpperCamelCase	(		self				)     -> Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    SwinvaModelTester(self				)
             __SCREAMING_SNAKE_CASE  :Any													=    ConfigTester(self						,config_class=a_						,embed_dim=37				)




       def        _UpperCamelCase	(		self				)     -> List[str]:





             """simple docstring"""






             self.config_tester.create_and_test_config_to_json_string()
             self.config_tester.create_and_test_config_to_json_file()
             self.config_tester.create_and_test_config_from_and_save_pretrained()
             self.config_tester.create_and_test_config_with_num_labels()
             self.config_tester.check_config_can_be_init_without_params()
             self.config_tester.check_config_arguments_init()




       def        _UpperCamelCase	(		self				)     -> List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Dict													=    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*a_				)




       @unittest.skip(reason='''Got `CUDA error: misaligned address` with PyTorch 2.0.0.'''				)
       def        _UpperCamelCase	(		self				)     -> Optional[int]:





             """simple docstring"""






             pass




       @unittest.skip(reason='''Swinv2 does not use inputs_embeds'''				)
       def        _UpperCamelCase	(		self				)     -> Optional[int]:





             """simple docstring"""






             pass




       def        _UpperCamelCase	(		self				)     -> List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :str													=    self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :Dict													=    model_class(a_				)
                   self.assertIsInstance(model.get_input_embeddings()						,(nn.Module)				)
                   __SCREAMING_SNAKE_CASE  :List[str]													=    model.get_output_embeddings()
                   self.assertTrue(x is None or isinstance(a_						,nn.Linear				)				)




       def        _UpperCamelCase	(		self				)     -> List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Optional[int]													=    self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :Any													=    model_class(a_				)
                   __SCREAMING_SNAKE_CASE  :Dict													=    inspect.signature(model.forward				)
                   # signature.parameters is an OrderedDict => so arg_names order is deterministic
                   __SCREAMING_SNAKE_CASE  :str													=    [*signature.parameters.keys()]

                   __SCREAMING_SNAKE_CASE  :Dict													=    ["pixel_values"]
                   self.assertListEqual(arg_names[:1]						,a_				)




       def        _UpperCamelCase	(		self				)     -> int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :str													=    self.model_tester.prepare_config_and_inputs_for_common()
             __SCREAMING_SNAKE_CASE  :str													=    True

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :str													=    True
                   __SCREAMING_SNAKE_CASE  :List[str]													=    False
                   __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    True
                   __SCREAMING_SNAKE_CASE  :Any													=    model_class(a_				)
                   model.to(a_				)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE  :Optional[Any]													=    model(**self._prepare_for_class(a_						,a_				)				)
                   __SCREAMING_SNAKE_CASE  :List[str]													=    outputs.attentions
                   __SCREAMING_SNAKE_CASE  :Tuple													=    len(self.model_tester.depths				)
                   self.assertEqual(len(a_				)						,a_				)

                   # check that output_attentions also work using config
                   del inputs_dict["output_attentions"]
                   __SCREAMING_SNAKE_CASE  :List[Any]													=    True
                   __SCREAMING_SNAKE_CASE  :Dict													=    config.window_size**2
                   __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    model_class(a_				)
                   model.to(a_				)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE  :str													=    model(**self._prepare_for_class(a_						,a_				)				)
                   __SCREAMING_SNAKE_CASE  :Any													=    outputs.attentions
                   self.assertEqual(len(a_				)						,a_				)

                   self.assertListEqual(
                       list(attentions[0].shape[-3:]				)						,[self.model_tester.num_heads[0], window_size_squared, window_size_squared]						,)
                   __SCREAMING_SNAKE_CASE  :str													=    len(a_				)

                   # Check attention is always last and order is fine
                   __SCREAMING_SNAKE_CASE  :List[str]													=    True
                   __SCREAMING_SNAKE_CASE  :Dict													=    True
                   __SCREAMING_SNAKE_CASE  :Any													=    model_class(a_				)
                   model.to(a_				)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE  :str													=    model(**self._prepare_for_class(a_						,a_				)				)

                   if hasattr(self.model_tester						,'''num_hidden_states_types'''				):
                         __SCREAMING_SNAKE_CASE  :int													=    self.model_tester.num_hidden_states_types
                   else:
                         # also another +1 for reshaped_hidden_states
                         __SCREAMING_SNAKE_CASE  :str													=    2
                   self.assertEqual(out_len + added_hidden_states						,len(a_				)				)

                   __SCREAMING_SNAKE_CASE  :List[str]													=    outputs.attentions

                   self.assertEqual(len(a_				)						,a_				)

                   self.assertListEqual(
                       list(self_attentions[0].shape[-3:]				)						,[self.model_tester.num_heads[0], window_size_squared, window_size_squared]						,)




       def        _UpperCamelCase	(		self						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__						,SCREAMING_SNAKE_CASE__				)     -> Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    model_class(a_				)
             model.to(a_				)
             model.eval()

             with torch.no_grad():
                   __SCREAMING_SNAKE_CASE  :List[str]													=    model(**self._prepare_for_class(a_						,a_				)				)

             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    outputs.hidden_states

             __SCREAMING_SNAKE_CASE  :Tuple													=    getattr(
                 self.model_tester						,'''expected_num_hidden_layers'''						,len(self.model_tester.depths				) + 1				)
             self.assertEqual(len(a_				)						,a_				)

             # Swinv2 has a different seq_length
             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    (
                 config.patch_size
                 if isinstance(config.patch_size						,collections.abc.Iterable				)
                 else (config.patch_size, config.patch_size)
             )

             __SCREAMING_SNAKE_CASE  :int													=    (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

             self.assertListEqual(
                 list(hidden_states[0].shape[-2:]				)						,[num_patches, self.model_tester.embed_dim]						,)

             __SCREAMING_SNAKE_CASE  :Tuple													=    outputs.reshaped_hidden_states
             self.assertEqual(len(a_				)						,a_				)

             __SCREAMING_SNAKE_CASE  :Any													=    reshaped_hidden_states[0].shape
             __SCREAMING_SNAKE_CASE  :Tuple													=    (
                 reshaped_hidden_states[0].view(a_						,a_						,height * width				).permute(0						,2						,1				)
             )
             self.assertListEqual(
                 list(reshaped_hidden_states.shape[-2:]				)						,[num_patches, self.model_tester.embed_dim]						,)




       def        _UpperCamelCase	(		self				)     -> str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :int													=    self.model_tester.prepare_config_and_inputs_for_common()

             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    (
                 self.model_tester.image_size
                 if isinstance(self.model_tester.image_size						,collections.abc.Iterable				)
                 else (self.model_tester.image_size, self.model_tester.image_size)
             )

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :int													=    True
                   self.check_hidden_states_output(a_						,a_						,a_						,a_				)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   __SCREAMING_SNAKE_CASE  :str													=    True

                   self.check_hidden_states_output(a_						,a_						,a_						,a_				)




       def        _UpperCamelCase	(		self				)     -> Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :int													=    self.model_tester.prepare_config_and_inputs_for_common()
             __SCREAMING_SNAKE_CASE  :int													=    3

             __SCREAMING_SNAKE_CASE  :List[str]													=    (
                 self.model_tester.image_size
                 if isinstance(self.model_tester.image_size						,collections.abc.Iterable				)
                 else (self.model_tester.image_size, self.model_tester.image_size)
             )
             __SCREAMING_SNAKE_CASE  :List[str]													=    (
                 config.patch_size
                 if isinstance(config.patch_size						,collections.abc.Iterable				)
                 else (config.patch_size, config.patch_size)
             )

             __SCREAMING_SNAKE_CASE  :Optional[Any]													=    image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
             __SCREAMING_SNAKE_CASE  :Union[str, Any]													=    image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :Dict													=    True
                   self.check_hidden_states_output(a_						,a_						,a_						,(padded_height, padded_width)				)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   __SCREAMING_SNAKE_CASE  :List[str]													=    True
                   self.check_hidden_states_output(a_						,a_						,a_						,(padded_height, padded_width)				)




       def        _UpperCamelCase	(		self				)     -> int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :List[str]													=    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_masked_image_modeling(*a_				)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :str													=    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_image_classification(*a_				)




       @slow
       def        _UpperCamelCase	(		self				)     -> Tuple:





             """simple docstring"""






             for model_name in SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                   __SCREAMING_SNAKE_CASE  :Tuple													=    SwinvaModel.from_pretrained(a_				)
                   self.assertIsNotNone(a_				)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :int													=    self.model_tester.prepare_config_and_inputs_for_common()

             __SCREAMING_SNAKE_CASE  :List[Any]													=    _config_zero_init(a_				)
             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE  :int													=    model_class(config=a_				)
                   for name, param in model.named_parameters():
                         if "embeddings" not in name and "logit_scale" not in name and param.requires_grad:
                               self.assertIn(
                                   ((param.data.mean() * 1E9).round() / 1E9).item()						,[0.0, 1.0]						,msg=f'''Parameter {name} of model {model_class} seems not properly initialized'''						,)






@require_vision
@require_torch
class    _SCREAMING_SNAKE_CASE(  unittest.TestCase    ):




       @cached_property
       def        _UpperCamelCase	(		self				)     -> Any:





             """simple docstring"""






             return (
                 AutoImageProcessor.from_pretrained('''microsoft/swinv2-tiny-patch4-window8-256'''				)
                 if is_vision_available()
                 else None
             )




       @slow
       def        _UpperCamelCase	(		self				)     -> Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE  :List[str]													=    SwinvaForImageClassification.from_pretrained('''microsoft/swinv2-tiny-patch4-window8-256'''				).to(
                 a_				)
             __SCREAMING_SNAKE_CASE  :str													=    self.default_image_processor

             __SCREAMING_SNAKE_CASE  :Tuple													=    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''				)
             __SCREAMING_SNAKE_CASE  :List[Any]													=    image_processor(images=a_						,return_tensors='''pt'''				).to(a_				)

             # forward pass
             with torch.no_grad():
                   __SCREAMING_SNAKE_CASE  :List[Any]													=    model(**a_				)

             # verify the logits
             __SCREAMING_SNAKE_CASE  :int													=    torch.Size((1, 10_00)				)
             self.assertEqual(outputs.logits.shape						,a_				)
             __SCREAMING_SNAKE_CASE  :Dict													=    torch.tensor([-0.3_9_4_7, -0.4_3_0_6, 0.0_0_2_6]				).to(a_				)
             self.assertTrue(torch.allclose(outputs.logits[0, :3]						,a_						,atol=1E-4				)				)



'''simple docstring'''
from typing import TYPE_CHECKING

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


lowerCAmelCase   : List[Any]             =				{
    """configuration_albert""": ["""ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AlbertConfig""", """AlbertOnnxConfig"""],
}

try:
					if not is_sentencepiece_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase   : Any             =				["""AlbertTokenizer"""]

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase   : Optional[Any]             =				["""AlbertTokenizerFast"""]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase   : List[str]             =				[
					    """ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """AlbertForMaskedLM""",
					    """AlbertForMultipleChoice""",
					    """AlbertForPreTraining""",
					    """AlbertForQuestionAnswering""",
					    """AlbertForSequenceClassification""",
					    """AlbertForTokenClassification""",
					    """AlbertModel""",
					    """AlbertPreTrainedModel""",
					    """load_tf_weights_in_albert""",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase   : Tuple             =				[
					    """TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """TFAlbertForMaskedLM""",
					    """TFAlbertForMultipleChoice""",
					    """TFAlbertForPreTraining""",
					    """TFAlbertForQuestionAnswering""",
					    """TFAlbertForSequenceClassification""",
					    """TFAlbertForTokenClassification""",
					    """TFAlbertMainLayer""",
					    """TFAlbertModel""",
					    """TFAlbertPreTrainedModel""",
					]

try:
					if not is_flax_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase   : Optional[int]             =				[
					    """FlaxAlbertForMaskedLM""",
					    """FlaxAlbertForMultipleChoice""",
					    """FlaxAlbertForPreTraining""",
					    """FlaxAlbertForQuestionAnswering""",
					    """FlaxAlbertForSequenceClassification""",
					    """FlaxAlbertForTokenClassification""",
					    """FlaxAlbertModel""",
					    """FlaxAlbertPreTrainedModel""",
					]

if TYPE_CHECKING:
					from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, AlbertOnnxConfig

					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_albert import AlbertTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_albert_fast import AlbertTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_albert import (
										    ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    AlbertForMaskedLM,
										    AlbertForMultipleChoice,
										    AlbertForPreTraining,
										    AlbertForQuestionAnswering,
										    AlbertForSequenceClassification,
										    AlbertForTokenClassification,
										    AlbertModel,
										    AlbertPreTrainedModel,
										    load_tf_weights_in_albert,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_albert import (
										    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFAlbertForMaskedLM,
										    TFAlbertForMultipleChoice,
										    TFAlbertForPreTraining,
										    TFAlbertForQuestionAnswering,
										    TFAlbertForSequenceClassification,
										    TFAlbertForTokenClassification,
										    TFAlbertMainLayer,
										    TFAlbertModel,
										    TFAlbertPreTrainedModel,
										)

					try:
										if not is_flax_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flax_albert import (
										    FlaxAlbertForMaskedLM,
										    FlaxAlbertForMultipleChoice,
										    FlaxAlbertForPreTraining,
										    FlaxAlbertForQuestionAnswering,
										    FlaxAlbertForSequenceClassification,
										    FlaxAlbertForTokenClassification,
										    FlaxAlbertModel,
										    FlaxAlbertPreTrainedModel,
										)
else:
					import sys

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


