
"""simple docstring"""




import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VivitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor


if is_torch_available():
					import torch
					from torch import nn

					from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VivitForVideoClassification, VivitModel
					from transformers.models.vivit.modeling_vivit import VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from transformers import VivitImageProcessor



class      lowerCAmelCase_						:


				"""simple docstring"""



				def __init__(self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__=2       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=10       ,	SCREAMING_SNAKE_CASE__=10       ,	SCREAMING_SNAKE_CASE__=8       ,	SCREAMING_SNAKE_CASE__=[2, 4, 4]       ,	SCREAMING_SNAKE_CASE__=3       ,	SCREAMING_SNAKE_CASE__=7_68       ,	SCREAMING_SNAKE_CASE__=5       ,	SCREAMING_SNAKE_CASE__=4       ,	SCREAMING_SNAKE_CASE__=37       ,	SCREAMING_SNAKE_CASE__="gelu_fast"       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=0.0       ,	SCREAMING_SNAKE_CASE__=0.02       ,	SCREAMING_SNAKE_CASE__=1E-06       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=None       ,	) ->		Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Tuple									=       parent
											SCREAMING_SNAKE_CASE__						:	int									=       batch_size
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       is_training
											SCREAMING_SNAKE_CASE__						:	Tuple									=       use_labels
											SCREAMING_SNAKE_CASE__						:	int									=       num_labels
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       image_size
											SCREAMING_SNAKE_CASE__						:	List[str]									=       num_frames
											SCREAMING_SNAKE_CASE__						:	List[str]									=       tubelet_size
											SCREAMING_SNAKE_CASE__						:	Tuple									=       num_channels
											SCREAMING_SNAKE_CASE__						:	Any									=       hidden_size
											SCREAMING_SNAKE_CASE__						:	Dict									=       num_hidden_layers
											SCREAMING_SNAKE_CASE__						:	Dict									=       num_attention_heads
											SCREAMING_SNAKE_CASE__						:	Any									=       intermediate_size
											SCREAMING_SNAKE_CASE__						:	List[str]									=       hidden_act
											SCREAMING_SNAKE_CASE__						:	Tuple									=       hidden_dropout_prob
											SCREAMING_SNAKE_CASE__						:	Any									=       attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE__						:	str									=       initializer_range
											SCREAMING_SNAKE_CASE__						:	List[str]									=       layer_norm_eps
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       qkv_bias
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       scope

											SCREAMING_SNAKE_CASE__						:	Tuple									=       (
											    (self.image_size // self.tubelet_size[2])
											    * (self.image_size // self.tubelet_size[1])
											    * (self.num_frames // self.tubelet_size[0])
											) + 1  # CLS token



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       floats_tensor(
											    [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size]   )

											SCREAMING_SNAKE_CASE__						:	str									=       None
											if self.use_labels:
																		SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       ids_tensor([self.batch_size]       ,	self.num_labels   )

											SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.get_config()

											return config, pixel_values, labels



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	int									=       VivitConfig(
											    num_frames=self.num_frames       ,	image_size=self.image_size       ,	tubelet_size=self.tubelet_size       ,	num_channels=self.num_channels       ,	hidden_size=self.hidden_size       ,	num_hidden_layers=self.num_hidden_layers       ,	num_attention_heads=self.num_attention_heads       ,	intermediate_size=self.intermediate_size       ,	hidden_act=self.hidden_act       ,	hidden_dropout_prob=self.hidden_dropout_prob       ,	attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,	initializer_range=self.initializer_range       ,	layer_norm_eps=self.layer_norm_eps       ,	qkv_bias=self.qkv_bias       ,	)
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       self.num_labels
											return config



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       VivitModel(config=SCREAMING_SNAKE_CASE__   )
											model.to(SCREAMING_SNAKE_CASE__   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	int									=       model(SCREAMING_SNAKE_CASE__   )
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, self.seq_length, self.hidden_size)   )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	int									=       VivitForVideoClassification(SCREAMING_SNAKE_CASE__   )
											model.to(SCREAMING_SNAKE_CASE__   )
											model.eval()

											SCREAMING_SNAKE_CASE__						:	str									=       model(SCREAMING_SNAKE_CASE__   )

											# verify the logits shape
											SCREAMING_SNAKE_CASE__						:	Tuple									=       torch.Size((self.batch_size, self.num_labels)   )
											self.parent.assertEqual(result.logits.shape       ,	SCREAMING_SNAKE_CASE__   )



				def      __magic_name__   (self   ) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Dict									=       self.prepare_config_and_inputs()
											SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Dict									=       config_and_inputs
											SCREAMING_SNAKE_CASE__						:	str									=       {"""pixel_values""": pixel_values}
											return config, inputs_dict






@require_torch
class      lowerCAmelCase_						(a__			, unittest.TestCase  ):


				"""simple docstring"""



				__UpperCamelCase				:						List[Any] 	=       (VivitModel, VivitForVideoClassification) if is_torch_available() else ()

				__UpperCamelCase				:						Tuple 	=       False
				__UpperCamelCase				:						Optional[Any] 	=       False
				__UpperCamelCase				:						Dict 	=       False
				__UpperCamelCase				:						Tuple 	=       False



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       VivitModelTester(self   )
											SCREAMING_SNAKE_CASE__						:	str									=       ConfigTester(self       ,	config_class=SCREAMING_SNAKE_CASE__       ,	has_text_modality=SCREAMING_SNAKE_CASE__       ,	hidden_size=37   )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       copy.deepcopy(SCREAMING_SNAKE_CASE__   )

											if return_labels:
																		if model_class in get_values(SCREAMING_SNAKE_CASE__   ):
																									SCREAMING_SNAKE_CASE__						:	List[Any]									=       torch.zeros(
																									    self.model_tester.batch_size       ,	dtype=torch.long       ,	device=SCREAMING_SNAKE_CASE__   )

											return inputs_dict



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											self.config_tester.run_common_tests()



				@unittest.skip(reason="""Vivit does not use inputs_embeds"""   )
				def      __magic_name__   (self   ) ->		List[Any]:



											"""simple docstring"""




											pass



				def      __magic_name__   (self   ) ->		Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Tuple									=       self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		SCREAMING_SNAKE_CASE__						:	Any									=       model_class(SCREAMING_SNAKE_CASE__   )
																		self.assertIsInstance(model.get_input_embeddings()       ,	(nn.Module)   )
																		SCREAMING_SNAKE_CASE__						:	Dict									=       model.get_output_embeddings()
																		self.assertTrue(x is None or isinstance(SCREAMING_SNAKE_CASE__       ,	nn.Linear   )   )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       model_class(SCREAMING_SNAKE_CASE__   )
																		SCREAMING_SNAKE_CASE__						:	Dict									=       inspect.signature(model.forward   )
																		# signature.parameters is an OrderedDict => so arg_names order is deterministic
																		SCREAMING_SNAKE_CASE__						:	Any									=       [*signature.parameters.keys()]

																		SCREAMING_SNAKE_CASE__						:	str									=       ["""pixel_values""", """head_mask"""]
																		self.assertListEqual(arg_names[:2]       ,	SCREAMING_SNAKE_CASE__   )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__   )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Tuple									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_video_classification(*SCREAMING_SNAKE_CASE__   )



				@slow
				def      __magic_name__   (self   ) ->		List[str]:



											"""simple docstring"""




											for model_name in VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       VivitModel.from_pretrained(SCREAMING_SNAKE_CASE__   )
																		self.assertIsNotNone(SCREAMING_SNAKE_CASE__   )



				def      __magic_name__   (self   ) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Any									=       self.model_tester.prepare_config_and_inputs_for_common()
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       True

											for model_class in self.all_model_classes:
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       self.model_tester.seq_length

																		SCREAMING_SNAKE_CASE__						:	str									=       True
																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       False
																		SCREAMING_SNAKE_CASE__						:	str									=       True
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       model_class(SCREAMING_SNAKE_CASE__   )
																		model.to(SCREAMING_SNAKE_CASE__   )
																		model.eval()
																		with torch.no_grad():
																									SCREAMING_SNAKE_CASE__						:	Dict									=       model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )   )
																		SCREAMING_SNAKE_CASE__						:	Any									=       outputs.attentions
																		self.assertEqual(len(SCREAMING_SNAKE_CASE__   )       ,	self.model_tester.num_hidden_layers   )

																		# check that output_attentions also work using config
																		del inputs_dict["output_attentions"]
																		SCREAMING_SNAKE_CASE__						:	List[Any]									=       True
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       model_class(SCREAMING_SNAKE_CASE__   )
																		model.to(SCREAMING_SNAKE_CASE__   )
																		model.eval()
																		with torch.no_grad():
																									SCREAMING_SNAKE_CASE__						:	Optional[int]									=       model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )   )
																		SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       outputs.attentions
																		self.assertEqual(len(SCREAMING_SNAKE_CASE__   )       ,	self.model_tester.num_hidden_layers   )

																		self.assertListEqual(
																		    list(attentions[0].shape[-3:]   )       ,	[self.model_tester.num_attention_heads, seq_len, seq_len]       ,	)
																		SCREAMING_SNAKE_CASE__						:	List[Any]									=       len(SCREAMING_SNAKE_CASE__   )

																		# Check attention is always last and order is fine
																		SCREAMING_SNAKE_CASE__						:	Tuple									=       True
																		SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       True
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       model_class(SCREAMING_SNAKE_CASE__   )
																		model.to(SCREAMING_SNAKE_CASE__   )
																		model.eval()
																		with torch.no_grad():
																									SCREAMING_SNAKE_CASE__						:	Tuple									=       model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )   )

																		self.assertEqual(out_len + 1       ,	len(SCREAMING_SNAKE_CASE__   )   )

																		SCREAMING_SNAKE_CASE__						:	str									=       outputs.attentions

																		self.assertEqual(len(SCREAMING_SNAKE_CASE__   )       ,	self.model_tester.num_hidden_layers   )

																		self.assertListEqual(
																		    list(self_attentions[0].shape[-3:]   )       ,	[self.model_tester.num_attention_heads, seq_len, seq_len]       ,	)



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											def check_hidden_states_output(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   ):
																		SCREAMING_SNAKE_CASE__						:	Any									=       model_class(SCREAMING_SNAKE_CASE__   )
																		model.to(SCREAMING_SNAKE_CASE__   )
																		model.eval()

																		with torch.no_grad():
																									SCREAMING_SNAKE_CASE__						:	List[str]									=       model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )   )

																		SCREAMING_SNAKE_CASE__						:	str									=       outputs.hidden_states
																		SCREAMING_SNAKE_CASE__						:	Any									=       self.model_tester.num_hidden_layers + 1
																		self.assertEqual(len(SCREAMING_SNAKE_CASE__   )       ,	SCREAMING_SNAKE_CASE__   )

																		SCREAMING_SNAKE_CASE__						:	Dict									=       self.model_tester.seq_length

																		self.assertListEqual(
																		    list(hidden_states[0].shape[-2:]   )       ,	[seq_length, self.model_tester.hidden_size]       ,	)

											SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
																		SCREAMING_SNAKE_CASE__						:	Any									=       True
																		check_hidden_states_output(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )

																		# check that output_hidden_states also work using config
																		del inputs_dict["output_hidden_states"]
																		SCREAMING_SNAKE_CASE__						:	int									=       True

																		check_hidden_states_output(SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__   )



				@unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""   )
				def      __magic_name__   (self   ) ->		Optional[int]:



											"""simple docstring"""




											pass






def lowercase_  (       ):
							SCREAMING_SNAKE_CASE__						:	List[str]									=       hf_hub_download(
							    repo_id="""hf-internal-testing/spaghetti-video"""       ,filename="""eating_spaghetti_32_frames.npy"""       ,repo_type="""dataset"""						)
							SCREAMING_SNAKE_CASE__						:	Optional[int]									=       np.load(_snake_case						)
							return list(_snake_case						)



@require_torch
@require_vision
class      lowerCAmelCase_						(unittest.TestCase  ):


				"""simple docstring"""



				@cached_property
				def      __magic_name__   (self   ) ->		str:



											"""simple docstring"""




											return VivitImageProcessor() if is_vision_available() else None



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       VivitForVideoClassification.from_pretrained("""google/vivit-b-16x2-kinetics400"""   ).to(SCREAMING_SNAKE_CASE__   )

											SCREAMING_SNAKE_CASE__						:	Any									=       self.default_image_processor
											SCREAMING_SNAKE_CASE__						:	Tuple									=       prepare_video()
											SCREAMING_SNAKE_CASE__						:	str									=       image_processor(SCREAMING_SNAKE_CASE__       ,	return_tensors="""pt"""   ).to(SCREAMING_SNAKE_CASE__   )

											# forward pass
											with torch.no_grad():
																		SCREAMING_SNAKE_CASE__						:	List[str]									=       model(**SCREAMING_SNAKE_CASE__   )

											# verify the logits
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       torch.Size((1, 4_00)   )
											self.assertEqual(outputs.logits.shape       ,	SCREAMING_SNAKE_CASE__   )

											# taken from original model
											SCREAMING_SNAKE_CASE__						:	Any									=       torch.tensor([-1.0543, 2.0764, -0.2104, 0.4439, -0.9658]   ).to(SCREAMING_SNAKE_CASE__   )

											self.assertTrue(torch.allclose(outputs.logits[0, :5]       ,	SCREAMING_SNAKE_CASE__       ,	atol=1E-4   )   )






"""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__   )




