




'''simple docstring'''





import math




class 			_snake_case		:




			def        lowerCAmelCase__    ( self    ,							a__    ,							a__							)    ->    int:

										'''simple docstring'''




										snake_case_      =				0.0
										snake_case_      =				0.0
										for i in range(len(a__							)							):
																	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        lowerCAmelCase__    ( self    ,							a__    ,							a__    ,							a__    ,							a__							)    ->    list[list[int | float]]:

										'''simple docstring'''




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


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							snake_case_      =				[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

																					# Compute the winning vector
																					snake_case_      =				self_organizing_map.get_winner(snake_case							,    snake_case					)

																					# Update the winning vector
																					snake_case_      =				self_organizing_map.update(snake_case							,    snake_case							,    snake_case							,    snake_case					)

    # classify test sample
							snake_case_      =				[0, 0, 0, 1]
							snake_case_      =				self_organizing_map.get_winner(snake_case							,    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()










'''simple docstring'''





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


_SCREAMING_SNAKE_CASE							:       List[Any]						=			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE							:       Optional[int]						=			{
    "edbeeching/decision-transformer-gym-hopper-medium": (
        "https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json"
    ),
    # See all DecisionTransformer models at https://huggingface.co/models?filter=decision_transformer
}




class 			_snake_case		(     lowercase_							):
			lowerCAmelCase_					:				Dict							=   "decision_transformer"
			lowerCAmelCase_					:				List[Any]							=   ["past_key_values"]
			lowerCAmelCase_					:				Tuple							=   {
			    "max_position_embeddings": "n_positions",
			    "num_attention_heads": "n_head",
			    "num_hidden_layers": "n_layer",
			}




			def __init__( self    ,							a__=17    ,							a__=4    ,							a__=128    ,							a__=4_096    ,							a__=True    ,							a__=1    ,							a__=1_024    ,							a__=3    ,							a__=1    ,							a__=None    ,							a__="relu"    ,							a__=0.1    ,							a__=0.1    ,							a__=0.1    ,							a__=1e-5    ,							a__=0.0_2    ,							a__=True    ,							a__=True    ,							a__=50_256    ,							a__=50_256    ,							a__=False    ,							a__=False    ,							**a__    ,							)    ->    Optional[int]:

										'''simple docstring'''




										snake_case_      =				state_dim
										snake_case_      =				act_dim
										snake_case_      =				hidden_size
										snake_case_      =				max_ep_len
										snake_case_      =				action_tanh
										snake_case_      =				vocab_size
										snake_case_      =				n_positions
										snake_case_      =				n_layer
										snake_case_      =				n_head
										snake_case_      =				n_inner
										snake_case_      =				activation_function
										snake_case_      =				resid_pdrop
										snake_case_      =				embd_pdrop
										snake_case_      =				attn_pdrop
										snake_case_      =				layer_norm_epsilon
										snake_case_      =				initializer_range
										snake_case_      =				scale_attn_weights
										snake_case_      =				use_cache
										snake_case_      =				scale_attn_by_inverse_layer_idx
										snake_case_      =				reorder_and_upcast_attn

										snake_case_      =				bos_token_id
										snake_case_      =				eos_token_id

										super().__init__(bos_token_id=a__    ,							eos_token_id=a__    ,							**a__							)




