

'''simple docstring'''





import math


class  UpperCAmelCase :

		'''simple docstring'''






		def 			UpperCamelCase(					self   ,			SCREAMING_SNAKE_CASE_   ,			SCREAMING_SNAKE_CASE_		)  ->     int:






							'''simple docstring'''



							lowerCamelCase_  				=      0.0
							lowerCamelCase_  				=      0.0
							for i in range(len(SCREAMING_SNAKE_CASE_		)		):
												da += math.pow((sample[i] - weights[0][i])   ,			2		)
												da += math.pow((sample[i] - weights[1][i])   ,			2		)
												return 0 if da > da else 1
							return 0






		def 			UpperCamelCase(					self   ,			SCREAMING_SNAKE_CASE_   ,			SCREAMING_SNAKE_CASE_   ,			SCREAMING_SNAKE_CASE_   ,			SCREAMING_SNAKE_CASE_		)  ->     list[list[int | float]]:






							'''simple docstring'''



							for i in range(len(SCREAMING_SNAKE_CASE_		)		):
												weights[j][i] += alpha * (sample[i] - weights[j][i])
							return weights







def   _UpperCamelCase	(		)       ->			None:
					# Training Examples ( m, n )
					lowerCamelCase_  				=      [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

					# weight initialization ( n, C )
					lowerCamelCase_  				=      [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

					# training
					lowerCamelCase_  				=      SelfOrganizingMap()
					lowerCamelCase_  				=      3
					lowerCamelCase_  				=      0.5

					for _ in range(__UpperCamelCase	):
										for j in range(len(__UpperCamelCase	)	):
															# training sample
															lowerCamelCase_  				=      training_samples[j]

															# Compute the winning vector
															lowerCamelCase_  				=      self_organizing_map.get_winner(__UpperCamelCase    ,__UpperCamelCase	)

															# Update the winning vector
															lowerCamelCase_  				=      self_organizing_map.update(__UpperCamelCase    ,__UpperCamelCase    ,__UpperCamelCase    ,__UpperCamelCase	)

    # classify test sample
					lowerCamelCase_  				=      [0, 0, 0, 1]
					lowerCamelCase_  				=      self_organizing_map.get_winner(__UpperCamelCase    ,__UpperCamelCase	)

					# results
					print(f'''Clusters that the test sample belongs to : {winner}'''	)
					print(f'''Weights that have been trained : {weights}'''	)


# running the main() function
if __name__ == "__main__":
				main()







"""simple docstring"""




from ...configuration_utils import PretrainedConfig
from ...utils import logging


__magic_name__						: str    =				logging.get_logger(__name__)

__magic_name__						: List[Any]    =				{
    'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json',
    'uclanlp/visualbert-vqa-pre': 'https://huggingface.co/uclanlp/visualbert-vqa-pre/resolve/main/config.json',
    'uclanlp/visualbert-vqa-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vqa-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-vcr': 'https://huggingface.co/uclanlp/visualbert-vcr/resolve/main/config.json',
    'uclanlp/visualbert-vcr-pre': 'https://huggingface.co/uclanlp/visualbert-vcr-pre/resolve/main/config.json',
    'uclanlp/visualbert-vcr-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vcr-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-nlvr2': 'https://huggingface.co/uclanlp/visualbert-nlvr2/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-pre': 'https://huggingface.co/uclanlp/visualbert-nlvr2-pre/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-nlvr2-coco-pre/resolve/main/config.json'
    )
    # See all VisualBERT models at https://huggingface.co/models?filter=visual_bert
}




class 			__snake_case   (lowerCamelCase  ):
							__a					 =       '''visual_bert'''




							def __init__(     self:    Any     ,							A_:    List[str]=3_05_22     ,							A_:    Tuple=7_68     ,							A_:    Dict=5_12     ,							A_:    List[Any]=12     ,							A_:    str=12     ,							A_:    Dict=30_72     ,							A_:    str="gelu"     ,							A_:    Union[str, Any]=0.1     ,							A_:    Any=0.1     ,							A_:    List[Any]=5_12     ,							A_:    int=2     ,							A_:    int=0.02     ,							A_:    Any=1E-12     ,							A_:    List[str]=False     ,							A_:    str=True     ,							A_:    Union[str, Any]=1     ,							A_:    Optional[int]=0     ,							A_:    Dict=2     ,							**A_:    Optional[int]     ,							):
										super().__init__(pad_token_id=A_     ,							bos_token_id=A_     ,							eos_token_id=A_     ,							**A_   )

										__lowerCamelCase          =      vocab_size
										__lowerCamelCase          =      max_position_embeddings
										__lowerCamelCase          =      hidden_size
										__lowerCamelCase          =      visual_embedding_dim
										__lowerCamelCase          =      num_hidden_layers
										__lowerCamelCase          =      num_attention_heads
										__lowerCamelCase          =      intermediate_size
										__lowerCamelCase          =      hidden_act
										__lowerCamelCase          =      hidden_dropout_prob
										__lowerCamelCase          =      attention_probs_dropout_prob
										__lowerCamelCase          =      initializer_range
										__lowerCamelCase          =      type_vocab_size
										__lowerCamelCase          =      layer_norm_eps
										__lowerCamelCase          =      bypass_transformer
										__lowerCamelCase          =      special_visual_initialize




