
"""simple docstring"""




from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


UpperCAmelCase__				:   Any   							=			logging.get_logger(__name__)

UpperCAmelCase__				:   Any   							=			{
    'google/bigbird-pegasus-large-arxiv': (
        'https://huggingface.co/google/bigbird-pegasus-large-arxiv/resolve/main/config.json'
    ),
    'google/bigbird-pegasus-large-pubmed': (
        'https://huggingface.co/google/bigbird-pegasus-large-pubmed/resolve/main/config.json'
    ),
    'google/bigbird-pegasus-large-bigpatent': (
        'https://huggingface.co/google/bigbird-pegasus-large-bigpatent/resolve/main/config.json'
    ),
    # See all BigBirdPegasus models at https://huggingface.co/models?filter=bigbird_pegasus
}



class      lowerCAmelCase_						(a__  ):


				"""simple docstring"""



				__UpperCamelCase				:						int 	=       '''bigbird_pegasus'''
				__UpperCamelCase				:						Tuple 	=       ['''past_key_values''']
				__UpperCamelCase				:						Tuple 	=       {
				    '''num_attention_heads''': '''encoder_attention_heads''',
				    '''hidden_size''': '''d_model''',
				    '''attention_probs_dropout_prob''': '''attention_dropout''',
				}



				def __init__(self       ,	SCREAMING_SNAKE_CASE__=9_61_03       ,	SCREAMING_SNAKE_CASE__=40_96       ,	SCREAMING_SNAKE_CASE__=16       ,	SCREAMING_SNAKE_CASE__=40_96       ,	SCREAMING_SNAKE_CASE__=16       ,	SCREAMING_SNAKE_CASE__=16       ,	SCREAMING_SNAKE_CASE__=40_96       ,	SCREAMING_SNAKE_CASE__=16       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__="gelu_new"       ,	SCREAMING_SNAKE_CASE__=10_24       ,	SCREAMING_SNAKE_CASE__=0.1       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=0.02       ,	SCREAMING_SNAKE_CASE__=2       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=0       ,	SCREAMING_SNAKE_CASE__=2       ,	SCREAMING_SNAKE_CASE__=1       ,	SCREAMING_SNAKE_CASE__="block_sparse"       ,	SCREAMING_SNAKE_CASE__=64       ,	SCREAMING_SNAKE_CASE__=3       ,	SCREAMING_SNAKE_CASE__=False       ,	**SCREAMING_SNAKE_CASE__       ,	) ->		List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       vocab_size
											SCREAMING_SNAKE_CASE__						:	int									=       max_position_embeddings
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       d_model
											SCREAMING_SNAKE_CASE__						:	Dict									=       encoder_ffn_dim
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       encoder_layers
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       encoder_attention_heads
											SCREAMING_SNAKE_CASE__						:	Dict									=       decoder_ffn_dim
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       decoder_layers
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       decoder_attention_heads
											SCREAMING_SNAKE_CASE__						:	Tuple									=       dropout
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       attention_dropout
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       activation_dropout
											SCREAMING_SNAKE_CASE__						:	str									=       activation_function
											SCREAMING_SNAKE_CASE__						:	List[str]									=       init_std
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       encoder_layerdrop
											SCREAMING_SNAKE_CASE__						:	Any									=       decoder_layerdrop
											SCREAMING_SNAKE_CASE__						:	str									=       classifier_dropout
											SCREAMING_SNAKE_CASE__						:	Dict									=       use_cache
											SCREAMING_SNAKE_CASE__						:	Dict									=       encoder_layers
											SCREAMING_SNAKE_CASE__						:	str									=       scale_embedding  # scale factor will be sqrt(d_model) if True

											# extra config
											SCREAMING_SNAKE_CASE__						:	List[str]									=       attention_type
											SCREAMING_SNAKE_CASE__						:	Any									=       block_size
											SCREAMING_SNAKE_CASE__						:	List[str]									=       num_random_blocks
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       use_bias

											super().__init__(
											    pad_token_id=SCREAMING_SNAKE_CASE__       ,	bos_token_id=SCREAMING_SNAKE_CASE__       ,	eos_token_id=SCREAMING_SNAKE_CASE__       ,	is_encoder_decoder=SCREAMING_SNAKE_CASE__       ,	decoder_start_token_id=SCREAMING_SNAKE_CASE__       ,	**SCREAMING_SNAKE_CASE__       ,	)






class      lowerCAmelCase_						(a__  ):


				"""simple docstring"""



				@property
				def      __magic_name__   (self   ) ->		Mapping[str, Mapping[int, str]]:



											"""simple docstring"""




											if self.task in ["default", "seq2seq-lm"]:
																		SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       OrderedDict(
																		    [
																		        ("""input_ids""", {0: """batch""", 1: """encoder_sequence"""}),
																		        ("""attention_mask""", {0: """batch""", 1: """encoder_sequence"""}),
																		    ]   )

																		if self.use_past:
																									SCREAMING_SNAKE_CASE__						:	List[Any]									=       {0: """batch"""}
																									SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       {0: """batch""", 1: """past_decoder_sequence + sequence"""}
																		else:
																									SCREAMING_SNAKE_CASE__						:	Tuple									=       {0: """batch""", 1: """decoder_sequence"""}
																									SCREAMING_SNAKE_CASE__						:	int									=       {0: """batch""", 1: """decoder_sequence"""}

																		if self.use_past:
																									self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE__       ,	direction="""inputs"""   )
											elif self.task == "causal-lm":
																		# TODO: figure this case out.
																		SCREAMING_SNAKE_CASE__						:	Dict									=       OrderedDict(
																		    [
																		        ("""input_ids""", {0: """batch""", 1: """encoder_sequence"""}),
																		        ("""attention_mask""", {0: """batch""", 1: """encoder_sequence"""}),
																		    ]   )
																		if self.use_past:
																									SCREAMING_SNAKE_CASE__						:	Optional[int]									=       self.num_layers
																									for i in range(SCREAMING_SNAKE_CASE__   ):
																																SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       {0: """batch""", 2: """past_sequence + sequence"""}
																																SCREAMING_SNAKE_CASE__						:	List[str]									=       {0: """batch""", 2: """past_sequence + sequence"""}
											else:
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       OrderedDict(
																		    [
																		        ("""input_ids""", {0: """batch""", 1: """encoder_sequence"""}),
																		        ("""attention_mask""", {0: """batch""", 1: """encoder_sequence"""}),
																		        ("""decoder_input_ids""", {0: """batch""", 1: """decoder_sequence"""}),
																		        ("""decoder_attention_mask""", {0: """batch""", 1: """decoder_sequence"""}),
																		    ]   )

											return common_inputs



				@property
				def      __magic_name__   (self   ) ->		Mapping[str, Mapping[int, str]]:



											"""simple docstring"""




											if self.task in ["default", "seq2seq-lm"]:
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       super().outputs
											else:
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       super(SCREAMING_SNAKE_CASE__       ,	self   ).outputs
																		if self.use_past:
																									SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.num_layers
																									for i in range(SCREAMING_SNAKE_CASE__   ):
																																SCREAMING_SNAKE_CASE__						:	Dict									=       {0: """batch""", 2: """past_sequence + sequence"""}
																																SCREAMING_SNAKE_CASE__						:	List[str]									=       {0: """batch""", 2: """past_sequence + sequence"""}
											return common_outputs



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = False       ,	SCREAMING_SNAKE_CASE__ = None       ,	) ->		Mapping[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
											    SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )

											# Generate decoder inputs
											SCREAMING_SNAKE_CASE__						:	List[str]									=       seq_length if not self.use_past else 1
											SCREAMING_SNAKE_CASE__						:	Any									=       self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
											    SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )
											SCREAMING_SNAKE_CASE__						:	Tuple									=       {F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
											SCREAMING_SNAKE_CASE__						:	Any									=       dict(**SCREAMING_SNAKE_CASE__       ,	**SCREAMING_SNAKE_CASE__   )

											if self.use_past:
																		if not is_torch_available():
																									raise ValueError("""Cannot generate dummy past_keys inputs without PyTorch installed."""   )
																		else:
																									import torch
																		SCREAMING_SNAKE_CASE__						:	List[Any]									=       common_inputs["""input_ids"""].shape
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       common_inputs["""decoder_input_ids"""].shape[1]
																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       self.num_attention_heads
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       (
																		    batch,
																		    num_encoder_attention_heads,
																		    encoder_seq_length,
																		    self._config.hidden_size // num_encoder_attention_heads,
																		)
																		SCREAMING_SNAKE_CASE__						:	str									=       decoder_seq_length + 3
																		SCREAMING_SNAKE_CASE__						:	Any									=       (
																		    batch,
																		    num_decoder_attention_heads,
																		    decoder_past_length,
																		    self._config.hidden_size // num_decoder_attention_heads,
																		)

																		SCREAMING_SNAKE_CASE__						:	List[Any]									=       torch.cat(
																		    [common_inputs["""decoder_attention_mask"""], torch.ones(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )]       ,	dim=1   )

																		SCREAMING_SNAKE_CASE__						:	str									=       []
																		# If the number of encoder and decoder layers are present in the model configuration, both are considered
																		SCREAMING_SNAKE_CASE__						:	Dict									=       self.num_layers
																		SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       min(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )
																		SCREAMING_SNAKE_CASE__						:	Dict									=       max(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ) - min_num_layers
																		SCREAMING_SNAKE_CASE__						:	int									=       """encoder""" if num_encoder_layers > num_decoder_layers else """decoder"""

																		for _ in range(SCREAMING_SNAKE_CASE__   ):
																									common_inputs["past_key_values"].append(
																									    (
																									        torch.zeros(SCREAMING_SNAKE_CASE__   ),
																									        torch.zeros(SCREAMING_SNAKE_CASE__   ),
																									        torch.zeros(SCREAMING_SNAKE_CASE__   ),
																									        torch.zeros(SCREAMING_SNAKE_CASE__   ),
																									    )   )
																		# TODO: test this.
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       encoder_shape if remaining_side_name == """encoder""" else decoder_shape
																		for _ in range(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ):
																									common_inputs["past_key_values"].append((torch.zeros(SCREAMING_SNAKE_CASE__   ), torch.zeros(SCREAMING_SNAKE_CASE__   ))   )
											return common_inputs



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = False       ,	SCREAMING_SNAKE_CASE__ = None       ,	) ->		Mapping[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Dict									=       self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
											    SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )

											if self.use_past:
																		if not is_torch_available():
																									raise ValueError("""Cannot generate dummy past_keys inputs without PyTorch installed."""   )
																		else:
																									import torch
																		SCREAMING_SNAKE_CASE__						:	Any									=       common_inputs["""input_ids"""].shape
																		# Not using the same length for past_key_values
																		SCREAMING_SNAKE_CASE__						:	str									=       seqlen + 2
																		SCREAMING_SNAKE_CASE__						:	int									=       self.num_layers
																		SCREAMING_SNAKE_CASE__						:	Any									=       self.num_attention_heads
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       (
																		    batch,
																		    num_encoder_attention_heads,
																		    past_key_values_length,
																		    self._config.hidden_size // num_encoder_attention_heads,
																		)

																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       common_inputs["""attention_mask"""].dtype
																		SCREAMING_SNAKE_CASE__						:	Dict									=       torch.cat(
																		    [common_inputs["""attention_mask"""], torch.ones(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	dtype=SCREAMING_SNAKE_CASE__   )]       ,	dim=1   )
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       [
																		    (torch.zeros(SCREAMING_SNAKE_CASE__   ), torch.zeros(SCREAMING_SNAKE_CASE__   )) for _ in range(SCREAMING_SNAKE_CASE__   )
																		]
											return common_inputs



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = False       ,	SCREAMING_SNAKE_CASE__ = None       ,	) ->		Mapping[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       compute_effective_axis_dimension(
											    SCREAMING_SNAKE_CASE__       ,	fixed_dimension=OnnxConfig.default_fixed_batch       ,	num_token_to_add=0   )

											# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
											SCREAMING_SNAKE_CASE__						:	Tuple									=       tokenizer.num_special_tokens_to_add(SCREAMING_SNAKE_CASE__   )
											SCREAMING_SNAKE_CASE__						:	str									=       compute_effective_axis_dimension(
											    SCREAMING_SNAKE_CASE__       ,	fixed_dimension=OnnxConfig.default_fixed_sequence       ,	num_token_to_add=SCREAMING_SNAKE_CASE__   )

											# Generate dummy inputs according to compute batch and sequence
											SCREAMING_SNAKE_CASE__						:	Tuple									=       [""" """.join([tokenizer.unk_token]   ) * seq_length] * batch_size
											SCREAMING_SNAKE_CASE__						:	List[str]									=       dict(tokenizer(SCREAMING_SNAKE_CASE__       ,	return_tensors=SCREAMING_SNAKE_CASE__   )   )
											return common_inputs



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = -1       ,	SCREAMING_SNAKE_CASE__ = False       ,	SCREAMING_SNAKE_CASE__ = None       ,	) ->		Mapping[str, Any]:



											"""simple docstring"""




											if self.task in ["default", "seq2seq-lm"]:
																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       self._generate_dummy_inputs_for_default_and_seqaseq_lm(
																		    SCREAMING_SNAKE_CASE__       ,	batch_size=SCREAMING_SNAKE_CASE__       ,	seq_length=SCREAMING_SNAKE_CASE__       ,	is_pair=SCREAMING_SNAKE_CASE__       ,	framework=SCREAMING_SNAKE_CASE__   )

											elif self.task == "causal-lm":
																		SCREAMING_SNAKE_CASE__						:	Any									=       self._generate_dummy_inputs_for_causal_lm(
																		    SCREAMING_SNAKE_CASE__       ,	batch_size=SCREAMING_SNAKE_CASE__       ,	seq_length=SCREAMING_SNAKE_CASE__       ,	is_pair=SCREAMING_SNAKE_CASE__       ,	framework=SCREAMING_SNAKE_CASE__   )
											else:
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
																		    SCREAMING_SNAKE_CASE__       ,	batch_size=SCREAMING_SNAKE_CASE__       ,	seq_length=SCREAMING_SNAKE_CASE__       ,	is_pair=SCREAMING_SNAKE_CASE__       ,	framework=SCREAMING_SNAKE_CASE__   )

											return common_inputs



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ) ->		Any:



											"""simple docstring"""




											if self.task in ["default", "seq2seq-lm"]:
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       super()._flatten_past_key_values_(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )
											else:
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       super(SCREAMING_SNAKE_CASE__       ,	self   )._flatten_past_key_values_(
																		    SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )






"""simple docstring"""




import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


if TYPE_CHECKING:
					import sqlitea

					import sqlalchemy


UpperCAmelCase__				:   Union[str, Any]   							=			datasets.utils.logging.get_logger(__name__)



@dataclass
class      lowerCAmelCase_						(datasets.BuilderConfig  ):


				"""simple docstring"""



				__UpperCamelCase				:						Union[str, "sqlalchemy.sql.Selectable"] 	=       None
				__UpperCamelCase				:						Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"] 	=       None
				__UpperCamelCase				:						Optional[Union[str, List[str]]] 	=       None
				__UpperCamelCase				:						bool 	=       True
				__UpperCamelCase				:						Optional[Union[List, Tuple, Dict]] 	=       None
				__UpperCamelCase				:						Optional[Union[List, Dict]] 	=       None
				__UpperCamelCase				:						Optional[List[str]] 	=       None
				__UpperCamelCase				:						Optional[int] 	=       10000
				__UpperCamelCase				:						Optional[datasets.Features] 	=       None



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											if self.sql is None:
																		raise ValueError("""sql must be specified"""   )
											if self.con is None:
																		raise ValueError("""con must be specified"""   )



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__ = None       ,	) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[Any]									=       config_kwargs.copy()
											# We need to stringify the Selectable object to make its hash deterministic

											# The process of stringifying is explained here: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
											SCREAMING_SNAKE_CASE__						:	Dict									=       config_kwargs["""sql"""]
											if not isinstance(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ):
																		if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
																									import sqlalchemy

																									if isinstance(SCREAMING_SNAKE_CASE__       ,	sqlalchemy.sql.Selectable   ):
																																SCREAMING_SNAKE_CASE__						:	str									=       sqlalchemy.create_engine(config_kwargs["""con"""].split("""://"""   )[0] + """://"""   )
																																SCREAMING_SNAKE_CASE__						:	Tuple									=       str(sql.compile(dialect=engine.dialect   )   )
																																SCREAMING_SNAKE_CASE__						:	Any									=       sql_str
																									else:
																																raise TypeError(
																																    F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(SCREAMING_SNAKE_CASE__   )}: {sql}'''   )
																		else:
																									raise TypeError(
																									    F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(SCREAMING_SNAKE_CASE__   )}: {sql}'''   )
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       config_kwargs["""con"""]
											if not isinstance(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ):
																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       id(SCREAMING_SNAKE_CASE__   )
																		logger.info(
																		    F'''SQL connection \'con\' of type {type(SCREAMING_SNAKE_CASE__   )} couldn\'t be hashed properly. To enable hashing, specify \'con\' as URI string instead.'''   )

											return super().create_config_id(SCREAMING_SNAKE_CASE__       ,	custom_features=SCREAMING_SNAKE_CASE__   )



				@property
				def      __magic_name__   (self   ) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       {
											    """index_col""": self.index_col,
											    """columns""": self.columns,
											    """params""": self.params,
											    """coerce_float""": self.coerce_float,
											    """parse_dates""": self.parse_dates,
											}
											return pd_read_sql_kwargs






class      lowerCAmelCase_						(datasets.ArrowBasedBuilder  ):


				"""simple docstring"""



				__UpperCamelCase				:						List[str] 	=       SqlConfig



				def      __magic_name__   (self   ) ->		List[Any]:



											"""simple docstring"""




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



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__   ) ->		List[str]:



											"""simple docstring"""




											return [datasets.SplitGenerator(name=datasets.Split.TRAIN       ,	gen_kwargs={}   )]



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__   ) ->		pa.Table:



											"""simple docstring"""




											if self.config.features is not None:
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       self.config.features.arrow_schema
																		if all(not require_storage_cast(SCREAMING_SNAKE_CASE__   ) for feature in self.config.features.values()   ):
																									# cheaper cast
																									SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       pa.Table.from_arrays([pa_table[field.name] for field in schema]       ,	schema=SCREAMING_SNAKE_CASE__   )
																		else:
																									# more expensive cast; allows str <-> int/float or str to Audio for example
																									SCREAMING_SNAKE_CASE__						:	Optional[int]									=       table_cast(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )
											return pa_table



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.config.chunksize
											SCREAMING_SNAKE_CASE__						:	Any									=       pd.read_sql(
											    self.config.sql       ,	self.config.con       ,	chunksize=SCREAMING_SNAKE_CASE__       ,	**self.config.pd_read_sql_kwargs   )
											SCREAMING_SNAKE_CASE__						:	str									=       [sql_reader] if chunksize is None else sql_reader
											for chunk_idx, df in enumerate(SCREAMING_SNAKE_CASE__   ):
																		SCREAMING_SNAKE_CASE__						:	int									=       pa.Table.from_pandas(SCREAMING_SNAKE_CASE__   )
																		yield chunk_idx, self._cast_table(SCREAMING_SNAKE_CASE__   )




