



"""simple docstring"""





import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
					import torch

					from transformers.activations import gelu_new, gelu_python, get_activation




@require_torch
class 			lowercase__			(      unittest.TestCase    ):
							'''simple docstring'''







							def        lowerCamelCase_   (  self						)			->							Any:
									_UpperCAmelCase							 =		torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]						)
									_UpperCAmelCase							 =		get_activation('gelu'						)
									self.assertTrue(torch.allclose(gelu_python(snake_case						)	,       torch_builtin(snake_case						)						)						)
									self.assertFalse(torch.allclose(gelu_python(snake_case						)	,       gelu_new(snake_case						)						)						)






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]						)
									_UpperCAmelCase							 =		get_activation('gelu'						)
									_UpperCAmelCase							 =		get_activation('gelu_10'						)

									_UpperCAmelCase							 =		torch_builtin(snake_case						)
									_UpperCAmelCase							 =		geluaa(snake_case						)

									_UpperCAmelCase							 =		torch.where(y_gelu_aa < 10.0	,       1	,       0						)

									self.assertTrue(torch.max(snake_case						).item() == 10.0						)
									self.assertTrue(torch.allclose(y_gelu * clipped_mask	,       y_gelu_aa * clipped_mask						)						)






							def        lowerCamelCase_   (  self						)			->							Tuple:
									get_activation('gelu'						)
									get_activation('gelu_10'						)
									get_activation('gelu_fast'						)
									get_activation('gelu_new'						)
									get_activation('gelu_python'						)
									get_activation('gelu_pytorch_tanh'						)
									get_activation('linear'						)
									get_activation('mish'						)
									get_activation('quick_gelu'						)
									get_activation('relu'						)
									get_activation('sigmoid'						)
									get_activation('silu'						)
									get_activation('swish'						)
									get_activation('tanh'						)
									with self.assertRaises(snake_case						):
											get_activation('bogus'						)
									with self.assertRaises(snake_case						):
											get_activation(snake_case						)






							def        lowerCamelCase_   (  self						)			->							Optional[Any]:
									_UpperCAmelCase							 =		get_activation('gelu'						)
									_UpperCAmelCase							 =		1
									_UpperCAmelCase							 =		get_activation('gelu'						)
									self.assertEqual(acta.a	,       1						)
									with self.assertRaises(snake_case						):
											_UpperCAmelCase							 =		acta.a







"""simple docstring"""





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase  							=					logging.get_logger(__name__)

lowercase  							=					{
    '''microsoft/beit-base-patch16-224-pt22k''': (
        '''https://huggingface.co/microsoft/beit-base-patch16-224-pt22k/resolve/main/config.json'''
    ),
    # See all BEiT models at https://huggingface.co/models?filter=beit
}




class 			lowercase__			(      A    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					'''beit'''






							def __init__(  self	,       snake_case=8192	,       snake_case=768	,       snake_case=12	,       snake_case=12	,       snake_case=3072	,       snake_case="gelu"	,       snake_case=0.0	,       snake_case=0.0	,       snake_case=0.02	,       snake_case=1E-12	,       snake_case=224	,       snake_case=16	,       snake_case=3	,       snake_case=False	,       snake_case=False	,       snake_case=False	,       snake_case=False	,       snake_case=0.1	,       snake_case=0.1	,       snake_case=True	,       snake_case=[3, 5, 7, 11]	,       snake_case=[1, 2, 3, 6]	,       snake_case=True	,       snake_case=0.4	,       snake_case=256	,       snake_case=1	,       snake_case=False	,       snake_case=255	,       **snake_case	,       )			->							str:
									super().__init__(**snake_case						)

									_UpperCAmelCase							 =		vocab_size
									_UpperCAmelCase							 =		hidden_size
									_UpperCAmelCase							 =		num_hidden_layers
									_UpperCAmelCase							 =		num_attention_heads
									_UpperCAmelCase							 =		intermediate_size
									_UpperCAmelCase							 =		hidden_act
									_UpperCAmelCase							 =		hidden_dropout_prob
									_UpperCAmelCase							 =		attention_probs_dropout_prob
									_UpperCAmelCase							 =		initializer_range
									_UpperCAmelCase							 =		layer_norm_eps

									_UpperCAmelCase							 =		image_size
									_UpperCAmelCase							 =		patch_size
									_UpperCAmelCase							 =		num_channels
									_UpperCAmelCase							 =		use_mask_token
									_UpperCAmelCase							 =		use_absolute_position_embeddings
									_UpperCAmelCase							 =		use_relative_position_bias
									_UpperCAmelCase							 =		use_shared_relative_position_bias
									_UpperCAmelCase							 =		layer_scale_init_value
									_UpperCAmelCase							 =		drop_path_rate
									_UpperCAmelCase							 =		use_mean_pooling
									# decode head attributes (semantic segmentation)
									_UpperCAmelCase							 =		out_indices
									_UpperCAmelCase							 =		pool_scales
									# auxiliary head attributes (semantic segmentation)
									_UpperCAmelCase							 =		use_auxiliary_head
									_UpperCAmelCase							 =		auxiliary_loss_weight
									_UpperCAmelCase							 =		auxiliary_channels
									_UpperCAmelCase							 =		auxiliary_num_convs
									_UpperCAmelCase							 =		auxiliary_concat_input
									_UpperCAmelCase							 =		semantic_loss_ignore_index







class 			lowercase__			(      A    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					version.parse('''1.11'''    )






							@property
							def        lowerCamelCase_   (  self						)			->							Mapping[str, Mapping[int, str]]:
									return OrderedDict(
									    [
									        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
									    ]						)






							@property
							def        lowerCamelCase_   (  self						)			->							float:
									return 1E-4


