





import pytest


__magic_name__   :						Tuple    =			"__dummy_dataset1__"

__magic_name__   :						str    =			"\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", \"validation\": REPO_URL + \"wikiann-bn-validation.jsonl\"}\n\n\nclass __DummyDataset1__(datasets.GeneratorBasedBuilder):\n\n    def _info(self):\n        features = datasets.Features(\n            {\n                \"tokens\": datasets.Sequence(datasets.Value(\"string\")),\n                \"ner_tags\": datasets.Sequence(\n                    datasets.features.ClassLabel(\n                        names=[\n                            \"O\",\n                            \"B-PER\",\n                            \"I-PER\",\n                            \"B-ORG\",\n                            \"I-ORG\",\n                            \"B-LOC\",\n                            \"I-LOC\",\n                        ]\n                    )\n                ),\n                \"langs\": datasets.Sequence(datasets.Value(\"string\")),\n                \"spans\": datasets.Sequence(datasets.Value(\"string\")),\n            }\n        )\n        return datasets.DatasetInfo(features=features)\n\n    def _split_generators(self, dl_manager):\n        dl_path = dl_manager.download(URLS)\n        return [\n            datasets.SplitGenerator(datasets.Split.TRAIN, gen_kwargs={\"filepath\": dl_path[\"train\"]}),\n            datasets.SplitGenerator(datasets.Split.VALIDATION, gen_kwargs={\"filepath\": dl_path[\"validation\"]}),\n        ]\n\n    def _generate_examples(self, filepath):\n        with open(filepath, \"r\", encoding=\"utf-8\") as f:\n            for i, line in enumerate(f):\n                yield i, json.loads(line)\n"




@pytest.fixture
def 				snake_case_      (		):







  '''simple docstring'''



  return DATASET_LOADING_SCRIPT_NAME




@pytest.fixture
def 				snake_case_      (		):







  '''simple docstring'''



  return DATASET_LOADING_SCRIPT_CODE




@pytest.fixture
def 				snake_case_      (		SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__       ):







  '''simple docstring'''



  _snake_case     		=				dataset_loading_script_name
  _snake_case     		=				tmp_path / "datasets" / script_name
  script_dir.mkdir(parents=_A       )
  _snake_case     		=				script_dir / f'''{script_name}.py'''
  with open(_A					,	"w"       ) as f:
    f.write(_A       )
  return str(_A       )









'''simple docstring'''



import math


class       __SCREAMING_SNAKE_CASE	:



     '''simple docstring'''






     def 	UpperCamelCase(					self						,   lowerCamelCase						,   lowerCamelCase	):
       _snake_case     		=				0.0
       _snake_case     		=				0.0
       for i in range(len(lowerCamelCase	)	):
         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						,   lowerCamelCase						,   lowerCamelCase						,   lowerCamelCase						,   lowerCamelCase	):
       for i in range(len(lowerCamelCase	)	):
         weights[j][i] += alpha * (sample[i] - weights[j][i])
       return weights







def 				snake_case_      (		):







  '''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(SCREAMING_SNAKE_CASE__       ):
    for j in range(len(SCREAMING_SNAKE_CASE__       )       ):
      # training sample
      _snake_case     		=				training_samples[j]

      # Compute the winning vector
      _snake_case     		=				self_organizing_map.get_winner(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__       )

      # Update the winning vector
      _snake_case     		=				self_organizing_map.update(SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__					,	SCREAMING_SNAKE_CASE__       )

    # classify test sample
  _snake_case     		=				[0, 0, 0, 1]
  _snake_case     		=				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()


