



import math
class 			_snake_case     :




				def 							A__ (  self   :  str,   __lowercase   :  list[list[float]],   __lowercase   :  list[int]  ):
							lowercase__   					=			0.0
							lowercase__   					=			0.0
							for i in range(len(__lowercase  )  ):
										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 							A__ (  self   :  int,   __lowercase   :  list[list[int | float]],   __lowercase   :  list[int],   __lowercase   :  int,   __lowercase   :  float  ):
							for i in range(len(__lowercase  )  ):
										weights[j][i] += alpha * (sample[i] - weights[j][i])
							return weights



def __lowerCAmelCase	(       ):
			# Training Examples ( m, n )
			lowercase__   					=			[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

									# Compute the winning vector
									lowercase__   					=			self_organizing_map.get_winner(SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					)

									# Update the winning vector
									lowercase__   					=			self_organizing_map.update(SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					)

    # classify test sample
			lowercase__   					=			[0, 0, 0, 1]
			lowercase__   					=			self_organizing_map.get_winner(SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					)

			# 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()




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


lowercase_						=       logging.get_logger(__name__)

lowercase_						=       {
    """facebook/dpr-ctx_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-ctx_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-multiset-base""": (
        """https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json"""
    ),
}
class 			_snake_case     (   lowercase__):
				UpperCamelCase__			:   str       						="""dpr"""




				def __init__(  self   :  int,   __lowercase   :  List[str]=3_0522,   __lowercase   :  Any=768,   __lowercase   :  Union[str, Any]=12,   __lowercase   :  Optional[int]=12,   __lowercase   :  List[Any]=3072,   __lowercase   :  List[str]="gelu",   __lowercase   :  Union[str, Any]=0.1,   __lowercase   :  str=0.1,   __lowercase   :  List[str]=512,   __lowercase   :  Optional[int]=2,   __lowercase   :  Dict=0.02,   __lowercase   :  Any=1e-1_2,   __lowercase   :  List[Any]=0,   __lowercase   :  str="absolute",   __lowercase   :  int = 0,   **__lowercase   :  str,   ):
							super().__init__(pad_token_id=__lowercase,   **__lowercase  )

							lowercase__   					=			vocab_size
							lowercase__   					=			hidden_size
							lowercase__   					=			num_hidden_layers
							lowercase__   					=			num_attention_heads
							lowercase__   					=			hidden_act
							lowercase__   					=			intermediate_size
							lowercase__   					=			hidden_dropout_prob
							lowercase__   					=			attention_probs_dropout_prob
							lowercase__   					=			max_position_embeddings
							lowercase__   					=			type_vocab_size
							lowercase__   					=			initializer_range
							lowercase__   					=			layer_norm_eps
							lowercase__   					=			projection_dim
							lowercase__   					=			position_embedding_type




