





'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

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


a__							:							Any			=logging.get_logger(__name__)

a__							:							Optional[int]			={
    '''uclanlp/plbart-base''': '''https://huggingface.co/uclanlp/plbart-base/resolve/main/config.json''',
    # See all PLBART models at https://huggingface.co/models?filter=plbart
}

class 					snake_case					(   __lowerCamelCase	):




	"""simple docstring"""



	SCREAMING_SNAKE_CASE_     : int      		="plbart"
	SCREAMING_SNAKE_CASE_     : List[Any]      		=["past_key_values"]
	SCREAMING_SNAKE_CASE_     : Optional[Any]      		={"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}






	def __init__(	self	:							List[str]							,     __A	:							Union[str, Any]=5_0_0_0_5							,     __A	:							List[Any]=1_0_2_4							,     __A	:							Optional[Any]=6							,     __A	:							Optional[int]=3_0_7_2							,     __A	:							Dict=1_2							,     __A	:							Any=6							,     __A	:							Optional[int]=3_0_7_2							,     __A	:							str=1_2							,     __A	:							int=0.0							,     __A	:							Optional[Any]=0.0							,     __A	:							Optional[int]=True							,     __A	:							List[str]=True							,     __A	:							Tuple="gelu"							,     __A	:							Optional[int]=7_6_8							,     __A	:							Dict=0.1							,     __A	:							Any=0.1							,     __A	:							Tuple=0.0							,     __A	:							Tuple=0.02							,     __A	:							int=0.0							,     __A	:							Optional[int]=True							,     __A	:							Union[str, Any]=1							,     __A	:							Tuple=0							,     __A	:							str=2							,     __A	:							Tuple=2							,     **__A	:							Tuple							,     ):
								__UpperCamelCase	=  vocab_size
								__UpperCamelCase	=  max_position_embeddings
								__UpperCamelCase	=  d_model
								__UpperCamelCase	=  encoder_ffn_dim
								__UpperCamelCase	=  encoder_layers
								__UpperCamelCase	=  encoder_attention_heads
								__UpperCamelCase	=  decoder_ffn_dim
								__UpperCamelCase	=  decoder_layers
								__UpperCamelCase	=  decoder_attention_heads
								__UpperCamelCase	=  dropout
								__UpperCamelCase	=  attention_dropout
								__UpperCamelCase	=  activation_dropout
								__UpperCamelCase	=  activation_function
								__UpperCamelCase	=  init_std
								__UpperCamelCase	=  encoder_layerdrop
								__UpperCamelCase	=  decoder_layerdrop
								__UpperCamelCase	=  classifier_dropout
								__UpperCamelCase	=  use_cache
								__UpperCamelCase	=  encoder_layers
								__UpperCamelCase	=  scale_embedding  # scale factor will be sqrt(d_model) if True
								super().__init__(
								    pad_token_id=__A							,     bos_token_id=__A							,     eos_token_id=__A							,     is_encoder_decoder=__A							,     forced_eos_token_id=__A							,     **__A							,     )






class 					snake_case					(   __lowerCamelCase	):




	"""simple docstring"""



	@property
	def 	_lowerCamelCase (	self	:							Optional[int]     ):
								return OrderedDict(
								    [
								        ('input_ids', {0: 'batch', 1: 'sequence'}),
								        ('attention_mask', {0: 'batch', 1: 'sequence'}),
								    ]     )






	@property
	def 	_lowerCamelCase (	self	:							Tuple     ):






								if self.use_past:
															return OrderedDict(
															    [
															        ('last_hidden_state', {0: 'batch', 1: 'sequence'}),
															        ('past_keys', {0: 'batch', 2: 'sequence'}),
															        ('encoder_last_hidden_state', {0: 'batch', 1: 'sequence'}),
															    ]     )
								else:
															return OrderedDict(
															    [
															        ('last_hidden_state', {0: 'batch', 1: 'sequence'}),
															        ('encoder_last_hidden_state', {0: 'batch', 1: 'sequence'}),
															    ]     )







'''simple docstring'''
import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


a__							:							Optional[Any]			=datasets.utils.logging.get_logger(__name__)

@dataclass
class 					snake_case					(   datasets.BuilderConfig	):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_     : Optional[datasets.Features]      		=None






class 					snake_case					(   datasets.ArrowBasedBuilder	):




 """simple docstring"""



 SCREAMING_SNAKE_CASE_     : int      		=ArrowConfig






 def 	_lowerCamelCase (	self	:							List[str]     ):
        return datasets.DatasetInfo(features=self.config.features     )






 def 	_lowerCamelCase (	self	:							Union[str, Any]							,     __A	:							Dict     ):
        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}'''     )
        __UpperCamelCase	=  dl_manager.download_and_extract(self.config.data_files     )
        if isinstance(__A							,     (str, list, tuple)     ):
               __UpperCamelCase	=  data_files
               if isinstance(__A							,     __A     ):
                      __UpperCamelCase	=  [files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               __UpperCamelCase	=  [dl_manager.iter_files(__A     ) for file in files]
               return [datasets.SplitGenerator(name=datasets.Split.TRAIN							,     gen_kwargs={'files': files}     )]
        __UpperCamelCase	=  []
        for split_name, files in data_files.items():
               if isinstance(__A							,     __A     ):
                      __UpperCamelCase	=  [files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               __UpperCamelCase	=  [dl_manager.iter_files(__A     ) 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(__A     ):
                             with open(__A							,     'rb'     ) as f:
                                    __UpperCamelCase	=  datasets.Features.from_arrow_schema(pa.ipc.open_stream(__A     ).schema     )
                             break
               splits.append(datasets.SplitGenerator(name=__A							,     gen_kwargs={'files': files}     )     )
        return splits






 def 	_lowerCamelCase (	self	:							Any							,     __A	:							pa.Table     ):
        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
               __UpperCamelCase	=  table_cast(__A							,     self.info.features.arrow_schema     )
        return pa_table






 def 	_lowerCamelCase (	self	:							int							,     __A	:							Optional[Any]     ):
        for file_idx, file in enumerate(itertools.chain.from_iterable(__A     )     ):
               with open(__A							,     'rb'     ) as f:
                      try:
                             for batch_idx, record_batch in enumerate(pa.ipc.open_stream(__A     )     ):
                                    __UpperCamelCase	=  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(__A     )
                      except ValueError as e:
                             logger.error(f'''Failed to read file \'{file}\' with error {type(__A     )}: {e}'''     )
                             raise
