



'''simple docstring'''



import itertools
from dataclasses import dataclass
from typing import List, Optional

import pyarrow as pa
import pyarrow.parquet as pq

import datasets
from datasets.table import table_cast


lowerCamelCase									=							datasets.utils.logging.get_logger(__name__)





@dataclass
class _UpperCamelCase		(  datasets.BuilderConfig		):





				'''simple docstring'''





				lowerCAmelCase__            =     1_00_00
				lowerCAmelCase__            =     None
				lowerCAmelCase__            =     None





class _UpperCamelCase		(  datasets.ArrowBasedBuilder		):





				'''simple docstring'''





				lowerCAmelCase__            =     ParquetConfig

				def 					__lowerCamelCase  (				self	:	Tuple):







											'''simple docstring'''

											return datasets.DatasetInfo(features=self.config.features)

				def 					__lowerCamelCase  (				self	:	int	,							_lowerCAmelCase	:	str):







											'''simple docstring'''

											if not self.config.data_files:
																		raise ValueError(f"""At least one data file must be specified, but got data_files={self.config.data_files}""")
											__lowercase													=dl_manager.download_and_extract(self.config.data_files)
											if isinstance(_UpperCamelCase	,							(str, list, tuple)):
																		__lowercase													=data_files
																		if isinstance(_UpperCamelCase	,							_UpperCamelCase):
																									__lowercase													=[files]
																		# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																		__lowercase													=[dl_manager.iter_files(_UpperCamelCase) for file in files]
																		return [datasets.SplitGenerator(name=datasets.Split.TRAIN	,							gen_kwargs={'files': files})]
											__lowercase													=[]
											for split_name, files in data_files.items():
																		if isinstance(_UpperCamelCase	,							_UpperCamelCase):
																									__lowercase													=[files]
																		# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																		__lowercase													=[dl_manager.iter_files(_UpperCamelCase) for file in files]
																		# Infer features is they are stoed in the arrow schema
																		if self.info.features is None:
																									for file in itertools.chain.from_iterable(_UpperCamelCase):
																																with open(_UpperCamelCase	,							'rb') as f:
																																							__lowercase													=datasets.Features.from_arrow_schema(pq.read_schema(_UpperCamelCase))
																																break
																		splits.append(datasets.SplitGenerator(name=_UpperCamelCase	,							gen_kwargs={'files': files}))
											return splits

				def 					__lowerCamelCase  (				self	:	Dict	,							_lowerCAmelCase	:	int):







											'''simple docstring'''

											if self.info.features is not None:
																		# more expensive cast to support nested features with keys in a different order
																		# allows str <-> int/float or str to Audio for example
																		__lowercase													=table_cast(_UpperCamelCase	,							self.info.features.arrow_schema)
											return pa_table

				def 					__lowerCamelCase  (				self	:	Optional[int]	,							_lowerCAmelCase	:	str):







											'''simple docstring'''

											__lowercase													=self.info.features.arrow_schema if self.info.features is not None else None
											if self.info.features is not None and self.config.columns is not None:
																		if sorted(field.name for field in schema) != sorted(self.config.columns):
																									raise ValueError(
																									    f"""Tried to load parquet data with columns '{self.config.columns}' with mismatching features '{self.info.features}'""")
											for file_idx, file in enumerate(itertools.chain.from_iterable(_UpperCamelCase)):
																		with open(_UpperCamelCase	,							'rb') as f:
																									__lowercase													=pq.ParquetFile(_UpperCamelCase)
																									try:
																																for batch_idx, record_batch in enumerate(
																																    parquet_file.iter_batches(batch_size=self.config.batch_size	,							columns=self.config.columns)):
																																							__lowercase													=pa.Table.from_batches([record_batch])
																																							# Uncomment for debugging (will print the Arrow table size and elements)
																																							# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
																																							# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
																																							yield f"""{file_idx}_{batch_idx}""", self._cast_table(_UpperCamelCase)
																									except ValueError as e:
																																logger.error(f"""Failed to read file '{file}' with error {type(_UpperCamelCase)}: {e}""")
																																raise





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  =	{
    "kssteven/ibert-roberta-base": "https://huggingface.co/kssteven/ibert-roberta-base/resolve/main/config.json",
    "kssteven/ibert-roberta-large": "https://huggingface.co/kssteven/ibert-roberta-large/resolve/main/config.json",
    "kssteven/ibert-roberta-large-mnli": (
        "https://huggingface.co/kssteven/ibert-roberta-large-mnli/resolve/main/config.json"
    ),
}





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




				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=1							,							_UpperCamelCase=0							,							_UpperCamelCase=2							,							_UpperCamelCase="absolute"							,							_UpperCamelCase=False							,							_UpperCamelCase="none"							,							**_UpperCamelCase							,							)							-> List[str]:
							super().__init__(pad_token_id=_UpperCamelCase							,							bos_token_id=_UpperCamelCase							,							eos_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_         =      quant_mode
							lowerCAmelCase_         =      force_dequant





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),
							    ]	)



