
from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset





class 			_lowerCAmelCase      (			__a ):




				def   __a		(      self  )       ->   Any:
							return [
							    {"col_1": 3, "col_2": "a"},
							    {"col_1": 2, "col_2": "b"},
							    {"col_1": 1, "col_2": "c"},
							    {"col_1": 0, "col_2": "d"},
							]




				def   __a		(      self  )       ->   Any:
							lowerCAmelCase_      			=			{"col_1": [3, 2, 1, 0], "col_2": ["a", "b", "c", "d"]}
							return Dataset.from_dict(_UpperCamelCase  )




				def   __a		(      self  )       ->   int:
							lowerCAmelCase_      			=			self._create_example_records()
							lowerCAmelCase_      			=			Dataset.from_list(_UpperCamelCase  )
							self.assertListEqual(dset.column_names       ,       ["col_1", "col_2"]  )
							for i, r in enumerate(_UpperCamelCase  ):
										self.assertDictEqual(_UpperCamelCase       ,       example_records[i]  )




				def   __a		(      self  )       ->   List[str]:
							lowerCAmelCase_      			=			self._create_example_records()
							lowerCAmelCase_      			=			Dataset.from_list(_UpperCamelCase  )
							lowerCAmelCase_      			=			Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]}  )
							self.assertEqual(dset.info       ,       dset_from_dict.info  )




				def   __a		(      self  )       ->   Optional[int]:  # checks what happens with missing columns
							lowerCAmelCase_      			=			[{"col_1": 1}, {"col_2": "x"}]
							lowerCAmelCase_      			=			Dataset.from_list(_UpperCamelCase  )
							self.assertDictEqual(dset[0]       ,       {"col_1": 1}  )
							self.assertDictEqual(dset[1]       ,       {"col_1": None}  )  # NB: first record is used for columns




				def   __a		(      self  )       ->   str:  # checks if the type can be inferred from the second record
							lowerCAmelCase_      			=			[{"col_1": []}, {"col_1": [1, 2]}]
							lowerCAmelCase_      			=			Dataset.from_list(_UpperCamelCase  )
							self.assertEqual(dset.info.features["col_1"]       ,       Sequence(Value("int64"  )  )  )




				def   __a		(      self  )       ->   Optional[int]:
							lowerCAmelCase_      			=			Dataset.from_list([]  )
							self.assertEqual(len(_UpperCamelCase  )       ,       0  )
							self.assertListEqual(dset.column_names       ,       []  )





from collections import OrderedDict
from typing import Mapping

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


_A     =  logging.get_logger(__name__)

_A     =  {
    "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/config.json",
    "bert-large-uncased": "https://huggingface.co/bert-large-uncased/resolve/main/config.json",
    "bert-base-cased": "https://huggingface.co/bert-base-cased/resolve/main/config.json",
    "bert-large-cased": "https://huggingface.co/bert-large-cased/resolve/main/config.json",
    "bert-base-multilingual-uncased": "https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json",
    "bert-base-multilingual-cased": "https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json",
    "bert-base-chinese": "https://huggingface.co/bert-base-chinese/resolve/main/config.json",
    "bert-base-german-cased": "https://huggingface.co/bert-base-german-cased/resolve/main/config.json",
    "bert-large-uncased-whole-word-masking": (
        "https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json"
    ),
    "bert-large-cased-whole-word-masking": (
        "https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json"
    ),
    "bert-large-uncased-whole-word-masking-finetuned-squad": (
        "https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json"
    ),
    "bert-large-cased-whole-word-masking-finetuned-squad": (
        "https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json"
    ),
    "bert-base-cased-finetuned-mrpc": "https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json",
    "bert-base-german-dbmdz-cased": "https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json",
    "bert-base-german-dbmdz-uncased": "https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json",
    "cl-tohoku/bert-base-japanese": "https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json",
    "cl-tohoku/bert-base-japanese-whole-word-masking": (
        "https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json"
    ),
    "cl-tohoku/bert-base-japanese-char": (
        "https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json"
    ),
    "cl-tohoku/bert-base-japanese-char-whole-word-masking": (
        "https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json"
    ),
    "TurkuNLP/bert-base-finnish-cased-v1": (
        "https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json"
    ),
    "TurkuNLP/bert-base-finnish-uncased-v1": (
        "https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json"
    ),
    "wietsedv/bert-base-dutch-cased": "https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json",
    # See all BERT models at https://huggingface.co/models?filter=bert
}





class 			_lowerCAmelCase      (			__a ):
				_lowercase    	='''bert'''




				def __init__(      self       ,       _UpperCamelCase=30_522       ,       _UpperCamelCase=768       ,       _UpperCamelCase=12       ,       _UpperCamelCase=12       ,       _UpperCamelCase=3_072       ,       _UpperCamelCase="gelu"       ,       _UpperCamelCase=0.1       ,       _UpperCamelCase=0.1       ,       _UpperCamelCase=512       ,       _UpperCamelCase=2       ,       _UpperCamelCase=0.02       ,       _UpperCamelCase=1e-1_2       ,       _UpperCamelCase=0       ,       _UpperCamelCase="absolute"       ,       _UpperCamelCase=True       ,       _UpperCamelCase=None       ,       **_UpperCamelCase       ,       )       ->   str:
							super().__init__(pad_token_id=_UpperCamelCase       ,       **_UpperCamelCase  )

							lowerCAmelCase_      			=			vocab_size
							lowerCAmelCase_      			=			hidden_size
							lowerCAmelCase_      			=			num_hidden_layers
							lowerCAmelCase_      			=			num_attention_heads
							lowerCAmelCase_      			=			hidden_act
							lowerCAmelCase_      			=			intermediate_size
							lowerCAmelCase_      			=			hidden_dropout_prob
							lowerCAmelCase_      			=			attention_probs_dropout_prob
							lowerCAmelCase_      			=			max_position_embeddings
							lowerCAmelCase_      			=			type_vocab_size
							lowerCAmelCase_      			=			initializer_range
							lowerCAmelCase_      			=			layer_norm_eps
							lowerCAmelCase_      			=			position_embedding_type
							lowerCAmelCase_      			=			use_cache
							lowerCAmelCase_      			=			classifier_dropout





class 			_lowerCAmelCase      (			__a ):




				@property
				def   __a		(      self  )       ->   Mapping[str, Mapping[int, str]]:
							if self.task == "multiple-choice":
										lowerCAmelCase_      			=			{0: "batch", 1: "choice", 2: "sequence"}
							else:
										lowerCAmelCase_      			=			{0: "batch", 1: "sequence"}
							return OrderedDict(
							    [
							        ("input_ids", dynamic_axis),
							        ("attention_mask", dynamic_axis),
							        ("token_type_ids", dynamic_axis),
							    ]  )



