



"""simple docstring"""







import copy
import os
import tempfile
from unittest import TestCase
from unittest.mock import patch

import numpy as np
import pyarrow as pa
import pyarrow.parquet as pq
import pytest

from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence
from datasets.features import ArrayaD, ClassLabel, Features, Image, Value
from datasets.features.features import ArrayaDExtensionType, cast_to_python_objects
from datasets.keyhash import DuplicatedKeysError, InvalidKeyError

from .utils import require_pil
class        __A       (	A_    ):







		'''simple docstring'''





		def 					UpperCAmelCase    (	self						:  Dict						)					->		List[str]:






				"""simple docstring"""



				lowercase__   :    int				=			pa.array(TypedSequence([1, 2, 3]						)						)
				self.assertEqual(arr.type			,pa.intaa()						)







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		int:






				"""simple docstring"""



				with self.assertRaises(_snake_case						):
						lowercase__   :    Optional[Any]				=			pa.array(TypedSequence([1, 2, 3]						)			,type=pa.intaa()						)







		def 					UpperCAmelCase    (	self						:  str						)					->		List[Any]:






				"""simple docstring"""



				with self.assertRaises(_snake_case						):
						lowercase__   :    Dict				=			pa.array(TypedSequence([1, 2, 3]			,try_type=Value('''bool'''						)			,type=Value('''int64'''						)						)						)







		def 					UpperCAmelCase    (	self						:  Any						)					->		Tuple:






				"""simple docstring"""



				lowercase__   :    Union[str, Any]				=			pa.array(TypedSequence([1, 2, 3]			,type=Value('''int32'''						)						)						)
				self.assertEqual(arr.type			,pa.intaa()						)







		def 					UpperCAmelCase    (	self						:  Optional[int]						)					->		Optional[int]:






				"""simple docstring"""



				with self.assertRaises((TypeError, pa.lib.ArrowInvalid)						):
						lowercase__   :    List[str]				=			pa.array(TypedSequence(['''foo''', '''bar''']			,type=Value('''int64'''						)						)						)







		def 					UpperCAmelCase    (	self						:  Optional[int]						)					->		Any:






				"""simple docstring"""



				lowercase__   :    Union[str, Any]				=			pa.array(TypedSequence([1, 2, 3]			,try_type=Value('''int32'''						)						)						)
				self.assertEqual(arr.type			,pa.intaa()						)







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Optional[Any]:






				"""simple docstring"""



				lowercase__   :    Dict				=			pa.array(TypedSequence(['''foo''', '''bar''']			,try_type=Value('''int64'''						)						)						)
				self.assertEqual(arr.type			,pa.string()						)







		def 					UpperCAmelCase    (	self						:  Tuple						)					->		List[str]:






				"""simple docstring"""



				lowercase__   :    str				=			pa.array(TypedSequence([[[1, 2, 3]]]			,type=ArrayaD((1, 3)			,'''int64'''						)						)						)
				self.assertEqual(arr.type			,ArrayaDExtensionType((1, 3)			,'''int64'''						)						)







		def 					UpperCAmelCase    (	self						:  Optional[int]						)					->		str:






				"""simple docstring"""



				with self.assertRaises((TypeError, pa.lib.ArrowInvalid)						):
						lowercase__   :    List[str]				=			pa.array(TypedSequence(['''foo''', '''bar''']			,type=ArrayaD((1, 3)			,'''int64'''						)						)						)







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Optional[Any]:






				"""simple docstring"""



				lowercase__   :    Tuple				=			pa.array(TypedSequence([[[1, 2, 3]]]			,try_type=ArrayaD((1, 3)			,'''int64'''						)						)						)
				self.assertEqual(arr.type			,ArrayaDExtensionType((1, 3)			,'''int64'''						)						)







		def 					UpperCAmelCase    (	self						:  Tuple						)					->		str:






				"""simple docstring"""



				lowercase__   :    List[Any]				=			pa.array(TypedSequence(['''foo''', '''bar''']			,try_type=ArrayaD((1, 3)			,'''int64'''						)						)						)
				self.assertEqual(arr.type			,pa.string()						)







		@require_pil
		def 					UpperCAmelCase    (	self						:  Any						)					->		int:






				"""simple docstring"""



				import PIL.Image

				lowercase__   :    List[Any]				=			PIL.Image.fromarray(np.arange(10			,dtype=np.uinta						).reshape(2			,5						)						)
				with patch(
				    '''datasets.arrow_writer.cast_to_python_objects'''			,side_effect=_snake_case						) as mock_cast_to_python_objects:
						lowercase__   :    int				=			pa.array(TypedSequence([{'''path''': None, '''bytes''': b'''image_bytes'''}, pil_image]			,type=Image()						)						)
						lowercase__		,			lowercase__   :    Tuple				=			mock_cast_to_python_objects.call_args_list[-1]
						self.assertIn('''optimize_list_casting'''			,_snake_case						)
						self.assertFalse(kwargs['''optimize_list_casting''']						)





def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      str:
		lowercase__   :    Optional[int]				=			pa.BufferReader(__lowerCamelCase	) if isinstance(__lowerCamelCase						,     pa.Buffer	) else pa.memory_map(__lowerCamelCase	)
		lowercase__   :    Dict				=			pa.ipc.open_stream(__lowerCamelCase	)
		lowercase__   :    pa.Table				=			f.read_all()
		assert len(pa_table.to_batches()	) == expected_num_chunks
		assert pa_table.to_pydict() == {"col_1": ["foo", "bar"], "col_2": [1, 2]}
		del pa_table



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 1, 10]	)
@pytest.mark.parametrize(
    '''fields'''						,     [None, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      List[Any]:
		lowercase__   :    List[Any]				=			pa.BufferOutputStream()
		lowercase__   :    Dict				=			pa.schema(__lowerCamelCase	) if fields else None
		with ArrowWriter(stream=__lowerCamelCase						,     schema=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase	) as writer:
				writer.write({'''col_1''': '''foo''', '''col_2''': 1}	)
				writer.write({'''col_1''': '''bar''', '''col_2''': 2}	)
				lowercase__		,			lowercase__   :    Tuple				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				lowercase__   :    Any				=			{'''col_1''': pa.string(), '''col_2''': pa.intaa()}
		assert writer._schema == pa.schema(__lowerCamelCase						,     metadata=writer._schema.metadata	)
		_check_output(output.getvalue()						,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1	)



def      __UpperCAmelCase      (    )							->      List[str]:
		lowercase__   :    List[Any]				=			pa.BufferOutputStream()
		lowercase__   :    str				=			Features({'''labels''': ClassLabel(names=['''neg''', '''pos''']	)}	)
		with ArrowWriter(stream=__lowerCamelCase						,     features=__lowerCamelCase	) as writer:
				writer.write({'''labels''': 0}	)
				writer.write({'''labels''': 1}	)
				lowercase__		,			lowercase__   :    Optional[Any]				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		assert writer._schema == features.arrow_schema
		assert writer._schema.metadata == features.arrow_schema.metadata
		lowercase__   :    Optional[int]				=			pa.BufferReader(output.getvalue()	)
		lowercase__   :    Tuple				=			pa.ipc.open_stream(__lowerCamelCase	)
		lowercase__   :    pa.Table				=			f.read_all()
		lowercase__   :    Dict				=			pa_table.schema
		assert pa_table.num_rows == 2
		assert schema == features.arrow_schema
		assert schema.metadata == features.arrow_schema.metadata
		assert features == Features.from_arrow_schema(__lowerCamelCase	)



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 1, 10]	)
def      __UpperCAmelCase      (    __lowerCamelCase	)							->      List[Any]:
		lowercase__   :    Optional[int]				=			pa.BufferOutputStream()
		with ArrowWriter(
		    stream=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase						,     hash_salt='''split_name'''						,     check_duplicates=__lowerCamelCase						,     ) as writer:
				with pytest.raises(__lowerCamelCase	):
						writer.write({'''col_1''': '''foo''', '''col_2''': 1}						,     key=[1, 2]	)
						lowercase__		,			lowercase__   :    Dict				=			writer.finalize()



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 2, 10]	)
def      __UpperCAmelCase      (    __lowerCamelCase	)							->      Any:
		lowercase__   :    str				=			pa.BufferOutputStream()
		with ArrowWriter(
		    stream=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase						,     hash_salt='''split_name'''						,     check_duplicates=__lowerCamelCase						,     ) as writer:
				with pytest.raises(__lowerCamelCase	):
						writer.write({'''col_1''': '''foo''', '''col_2''': 1}						,     key=10	)
						writer.write({'''col_1''': '''bar''', '''col_2''': 2}						,     key=10	)
						lowercase__		,			lowercase__   :    str				=			writer.finalize()



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 2, 10]	)
def      __UpperCAmelCase      (    __lowerCamelCase	)							->      Optional[Any]:
		lowercase__   :    str				=			pa.BufferOutputStream()
		with ArrowWriter(
		    stream=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase						,     hash_salt='''split_name'''						,     check_duplicates=__lowerCamelCase						,     ) as writer:
				writer.write({'''col_1''': '''foo''', '''col_2''': 1}						,     key=1	)
				writer.write({'''col_1''': '''bar''', '''col_2''': 2}						,     key=2	)
				lowercase__		,			lowercase__   :    List[str]				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		_check_output(output.getvalue()						,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1	)



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 1, 10]	)
@pytest.mark.parametrize(
    '''fields'''						,     [None, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      List[Any]:
		lowercase__   :    int				=			pa.BufferOutputStream()
		lowercase__   :    Tuple				=			pa.schema(__lowerCamelCase	) if fields else None
		with ArrowWriter(stream=__lowerCamelCase						,     schema=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase	) as writer:
				writer.write_batch({'''col_1''': ['''foo''', '''bar'''], '''col_2''': [1, 2]}	)
				writer.write_batch({'''col_1''': [], '''col_2''': []}	)
				lowercase__		,			lowercase__   :    List[Any]				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				lowercase__   :    Tuple				=			{'''col_1''': pa.string(), '''col_2''': pa.intaa()}
		assert writer._schema == pa.schema(__lowerCamelCase						,     metadata=writer._schema.metadata	)
		_check_output(output.getvalue()						,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1	)



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 1, 10]	)
@pytest.mark.parametrize(
    '''fields'''						,     [None, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[int]:
		lowercase__   :    Dict				=			pa.BufferOutputStream()
		lowercase__   :    Tuple				=			pa.schema(__lowerCamelCase	) if fields else None
		with ArrowWriter(stream=__lowerCamelCase						,     schema=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase	) as writer:
				writer.write_table(pa.Table.from_pydict({'''col_1''': ['''foo''', '''bar'''], '''col_2''': [1, 2]}	)	)
				lowercase__		,			lowercase__   :    Any				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				lowercase__   :    Any				=			{'''col_1''': pa.string(), '''col_2''': pa.intaa()}
		assert writer._schema == pa.schema(__lowerCamelCase						,     metadata=writer._schema.metadata	)
		_check_output(output.getvalue()						,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1	)



@pytest.mark.parametrize('''writer_batch_size'''						,     [None, 1, 10]	)
@pytest.mark.parametrize(
    '''fields'''						,     [None, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}, {'''col_1''': pa.string(), '''col_2''': pa.intaa()}]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[Any]:
		lowercase__   :    Dict				=			pa.BufferOutputStream()
		lowercase__   :    Dict				=			pa.schema(__lowerCamelCase	) if fields else None
		with ArrowWriter(stream=__lowerCamelCase						,     schema=__lowerCamelCase						,     writer_batch_size=__lowerCamelCase	) as writer:
				writer.write_row(pa.Table.from_pydict({'''col_1''': ['''foo'''], '''col_2''': [1]}	)	)
				writer.write_row(pa.Table.from_pydict({'''col_1''': ['''bar'''], '''col_2''': [2]}	)	)
				lowercase__		,			lowercase__   :    Dict				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				lowercase__   :    Optional[int]				=			{'''col_1''': pa.string(), '''col_2''': pa.intaa()}
		assert writer._schema == pa.schema(__lowerCamelCase						,     metadata=writer._schema.metadata	)
		_check_output(output.getvalue()						,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1	)



def      __UpperCAmelCase      (    )							->      int:
		with tempfile.TemporaryDirectory() as tmp_dir:
				lowercase__   :    Optional[int]				=			{'''col_1''': pa.string(), '''col_2''': pa.intaa()}
				lowercase__   :    Dict				=			os.path.join(__lowerCamelCase						,     '''test.arrow'''	)
				with ArrowWriter(path=__lowerCamelCase						,     schema=pa.schema(__lowerCamelCase	)	) as writer:
						writer.write_batch({'''col_1''': ['''foo''', '''bar'''], '''col_2''': [1, 2]}	)
						lowercase__		,			lowercase__   :    str				=			writer.finalize()
				assert num_examples == 2
				assert num_bytes > 0
				assert writer._schema == pa.schema(__lowerCamelCase						,     metadata=writer._schema.metadata	)
				_check_output(__lowerCamelCase						,     1	)



def      __UpperCAmelCase      (    __lowerCamelCase	)							->      Tuple:
		if pa.types.is_list(__lowerCamelCase	):
				return get_base_dtype(arr_type.value_type	)
		else:
				return arr_type



def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Dict:
		if isinstance(lst[0]						,     __lowerCamelCase	):
				change_first_primitive_element_in_list(lst[0]						,     __lowerCamelCase	)
		else:
				lowercase__   :    Optional[Any]				=			value



@pytest.mark.parametrize('''optimized_int_type, expected_dtype'''						,     [(None, pa.intaa()), (Value('''int32'''	), pa.intaa())]	)
@pytest.mark.parametrize('''sequence'''						,     [[1, 2, 3], [[1, 2, 3]], [[[1, 2, 3]]]]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[int]:
		lowercase__   :    Optional[int]				=			pa.array(TypedSequence(__lowerCamelCase						,     optimized_int_type=__lowerCamelCase	)	)
		assert get_base_dtype(arr.type	) == expected_dtype



@pytest.mark.parametrize(
    '''col, expected_dtype'''						,     [
        ('''attention_mask''', pa.inta()),
        ('''special_tokens_mask''', pa.inta()),
        ('''token_type_ids''', pa.inta()),
        ('''input_ids''', pa.intaa()),
        ('''other''', pa.intaa()),
    ]						,     )
@pytest.mark.parametrize('''sequence'''						,     [[1, 2, 3], [[1, 2, 3]], [[[1, 2, 3]]]]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase						,     __lowerCamelCase	)							->      Any:
		# in range
		lowercase__   :    Optional[int]				=			pa.array(OptimizedTypedSequence(__lowerCamelCase						,     col=__lowerCamelCase	)	)
		assert get_base_dtype(arr.type	) == expected_dtype

		# not in range
		if col != "other":
				# avoids errors due to in-place modifications
				lowercase__   :    Tuple				=			copy.deepcopy(__lowerCamelCase	)
				lowercase__   :    Dict				=			np.iinfo(expected_dtype.to_pandas_dtype()	).max + 1
				change_first_primitive_element_in_list(__lowerCamelCase						,     __lowerCamelCase	)
				lowercase__   :    int				=			pa.array(OptimizedTypedSequence(__lowerCamelCase						,     col=__lowerCamelCase	)	)
				assert get_base_dtype(arr.type	) == pa.intaa()



@pytest.mark.parametrize('''raise_exception'''						,     [False, True]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[int]:
		lowercase__   :    List[Any]				=			str(tmp_path / '''dataset-train.arrow'''	)
		try:
				with ArrowWriter(path=__lowerCamelCase	) as writer:
						if raise_exception:
								raise pa.lib.ArrowInvalid()
						else:
								writer.stream.close()
		except pa.lib.ArrowInvalid:
				pass
		finally:
				assert writer.stream.closed



def      __UpperCAmelCase      (    __lowerCamelCase	)							->      Union[str, Any]:
		lowercase__   :    int				=			'''mock://dataset-train.arrow'''
		with ArrowWriter(path=__lowerCamelCase						,     storage_options=mockfs.storage_options	) as writer:
				assert isinstance(writer._fs						,     type(__lowerCamelCase	)	)
				assert writer._fs.storage_options == mockfs.storage_options
				writer.write({'''col_1''': '''foo''', '''col_2''': 1}	)
				writer.write({'''col_1''': '''bar''', '''col_2''': 2}	)
				lowercase__		,			lowercase__   :    int				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		assert mockfs.exists(__lowerCamelCase	)



def      __UpperCAmelCase      (    )							->      Optional[int]:
		lowercase__   :    List[Any]				=			pa.BufferOutputStream()
		with ParquetWriter(stream=__lowerCamelCase	) as writer:
				writer.write({'''col_1''': '''foo''', '''col_2''': 1}	)
				writer.write({'''col_1''': '''bar''', '''col_2''': 2}	)
				lowercase__		,			lowercase__   :    List[str]				=			writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		lowercase__   :    str				=			pa.BufferReader(output.getvalue()	)
		lowercase__   :    pa.Table				=			pq.read_table(__lowerCamelCase	)
		assert pa_table.to_pydict() == {"col_1": ["foo", "bar"], "col_2": [1, 2]}



@require_pil
@pytest.mark.parametrize('''embed_local_files'''						,     [False, True]	)
def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Dict:
		import PIL.Image

		lowercase__   :    Dict				=			str(tmp_path / '''test_image_rgb.jpg'''	)
		PIL.Image.fromarray(np.zeros((5, 5)						,     dtype=np.uinta	)	).save(__lowerCamelCase						,     format='''png'''	)
		lowercase__   :    Tuple				=			pa.BufferOutputStream()
		with ParquetWriter(
		    stream=__lowerCamelCase						,     features=Features({'''image''': Image()}	)						,     embed_local_files=__lowerCamelCase	) as writer:
				writer.write({'''image''': image_path}	)
				writer.finalize()
		lowercase__   :    Any				=			pa.BufferReader(output.getvalue()	)
		lowercase__   :    pa.Table				=			pq.read_table(__lowerCamelCase	)
		lowercase__   :    Union[str, Any]				=			pa_table.to_pydict()
		if embed_local_files:
				assert isinstance(out['''image'''][0]['''path''']						,     __lowerCamelCase	)
				with open(__lowerCamelCase						,     '''rb'''	) as f:
						assert out["image"][0]["bytes"] == f.read()
		else:
				assert out["image"][0]["path"] == image_path
				assert out["image"][0]["bytes"] is None





def      __UpperCAmelCase      (    )							->      Union[str, Any]:
		lowercase__   :    Optional[Any]				=			pa.schema([pa.field('''col_1'''						,     pa.string()						,     nullable=__lowerCamelCase	)]	)
		lowercase__   :    List[Any]				=			pa.BufferOutputStream()
		with ArrowWriter(stream=__lowerCamelCase	) as writer:
				writer._build_writer(inferred_schema=__lowerCamelCase	)
				assert writer._schema == pa.schema([pa.field('''col_1'''						,     pa.string()	)]	)





"""simple docstring"""







from ...configuration_utils import PretrainedConfig


lowerCAmelCase_   						=   {
    'google/tapas-base-finetuned-sqa': (
        'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wtq': (
        'https://huggingface.co/google/tapas-base-finetuned-wtq/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wikisql-supervised': (
        'https://huggingface.co/google/tapas-base-finetuned-wikisql-supervised/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-tabfact': (
        'https://huggingface.co/google/tapas-base-finetuned-tabfact/resolve/main/config.json'
    ),
}
class        __A       (	A_    ):







		'''simple docstring'''





		lowerCAmelCase			:					str   	=				"tapas"







		def __init__(	self						:  List[Any]			,_snake_case						:  Dict=30_522			,_snake_case						:  Union[str, Any]=768			,_snake_case						:  int=12			,_snake_case						:  Union[str, Any]=12			,_snake_case						:  Union[str, Any]=3_072			,_snake_case						:  List[Any]="gelu"			,_snake_case						:  Optional[int]=0.1			,_snake_case						:  Tuple=0.1			,_snake_case						:  List[Any]=1_024			,_snake_case						:  Any=[3, 256, 256, 2, 256, 256, 10]			,_snake_case						:  List[Any]=0.02			,_snake_case						:  Union[str, Any]=1e-12			,_snake_case						:  str=0			,_snake_case						:  Any=10.0			,_snake_case						:  int=0			,_snake_case						:  Optional[Any]=1.0			,_snake_case						:  List[str]=None			,_snake_case						:  Tuple=1.0			,_snake_case						:  Tuple=False			,_snake_case						:  List[Any]=None			,_snake_case						:  int=1.0			,_snake_case						:  List[Any]=1.0			,_snake_case						:  Optional[int]=False			,_snake_case						:  Optional[int]=False			,_snake_case						:  Optional[int]="ratio"			,_snake_case						:  Any=None			,_snake_case						:  Union[str, Any]=None			,_snake_case						:  List[str]=64			,_snake_case						:  Optional[Any]=32			,_snake_case						:  Optional[Any]=False			,_snake_case						:  Optional[int]=True			,_snake_case						:  Dict=False			,_snake_case						:  Tuple=False			,_snake_case						:  int=True			,_snake_case						:  List[str]=False			,_snake_case						:  Dict=None			,_snake_case						:  Optional[int]=None			,**_snake_case						:  int			,)					->		List[Any]:






				"""simple docstring"""



				super().__init__(pad_token_id=_snake_case			,**_snake_case						)

				# BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
				lowercase__   :    Optional[int]				=			vocab_size
				lowercase__   :    List[str]				=			hidden_size
				lowercase__   :    Any				=			num_hidden_layers
				lowercase__   :    Optional[Any]				=			num_attention_heads
				lowercase__   :    Optional[int]				=			hidden_act
				lowercase__   :    List[Any]				=			intermediate_size
				lowercase__   :    List[Any]				=			hidden_dropout_prob
				lowercase__   :    Dict				=			attention_probs_dropout_prob
				lowercase__   :    str				=			max_position_embeddings
				lowercase__   :    Dict				=			type_vocab_sizes
				lowercase__   :    Optional[Any]				=			initializer_range
				lowercase__   :    Dict				=			layer_norm_eps

				# Fine-tuning task hyperparameters
				lowercase__   :    Any				=			positive_label_weight
				lowercase__   :    int				=			num_aggregation_labels
				lowercase__   :    List[str]				=			aggregation_loss_weight
				lowercase__   :    Optional[int]				=			use_answer_as_supervision
				lowercase__   :    Optional[Any]				=			answer_loss_importance
				lowercase__   :    Union[str, Any]				=			use_normalized_answer_loss
				lowercase__   :    str				=			huber_loss_delta
				lowercase__   :    str				=			temperature
				lowercase__   :    int				=			aggregation_temperature
				lowercase__   :    List[Any]				=			use_gumbel_for_cells
				lowercase__   :    Tuple				=			use_gumbel_for_aggregation
				lowercase__   :    Union[str, Any]				=			average_approximation_function
				lowercase__   :    Union[str, Any]				=			cell_selection_preference
				lowercase__   :    Any				=			answer_loss_cutoff
				lowercase__   :    List[Any]				=			max_num_rows
				lowercase__   :    str				=			max_num_columns
				lowercase__   :    int				=			average_logits_per_cell
				lowercase__   :    str				=			select_one_column
				lowercase__   :    str				=			allow_empty_column_selection
				lowercase__   :    Any				=			init_cell_selection_weights_to_zero
				lowercase__   :    Optional[int]				=			reset_position_index_per_cell
				lowercase__   :    Union[str, Any]				=			disable_per_token_loss

				# Aggregation hyperparameters
				lowercase__   :    Optional[Any]				=			aggregation_labels
				lowercase__   :    List[Any]				=			no_aggregation_label_index

				if isinstance(self.aggregation_labels			,_snake_case						):
						lowercase__   :    Union[str, Any]				=			{int(_snake_case						): v for k, v in aggregation_labels.items()}
