code: 
  
  
  
  
  
  
  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
  
  
  lowerCamelCase										=  datasets.utils.logging.get_logger(__name__)
  
  @dataclass
  class 					snake_case_							(       datasets.BuilderConfig      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						True
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						None
     __lowerCAmelCase      =						1_00_00
     __lowerCAmelCase      =						None
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[Any]	)  ->		Optional[int]:
  
  
         """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 			SCREAMING_SNAKE_CASE__				(    self:	Dict   ,       snake_case__:	dict   ,       snake_case__:	Optional[datasets.Features] = None   ,       )  ->		str:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	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
         _lowercase     =	config_kwargs['sql']
         if not isinstance(snake_case__   ,       snake_case__	):
             if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
                 import sqlalchemy
  
                 if isinstance(snake_case__   ,       sqlalchemy.sql.Selectable	):
                     _lowercase     =	sqlalchemy.create_engine(config_kwargs['con'].split('://'	)[0] + '://'	)
                     _lowercase     =	str(sql.compile(dialect=engine.dialect	)	)
                     _lowercase     =	sql_str
                 else:
                     raise TypeError(
                         f'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(snake_case__	)}: {sql}'''	)
             else:
                 raise TypeError(
                     f'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(snake_case__	)}: {sql}'''	)
         _lowercase     =	config_kwargs['con']
         if not isinstance(snake_case__   ,       snake_case__	):
             _lowercase     =	id(snake_case__	)
             logger.info(
                 f'''SQL connection \'con\' of type {type(snake_case__	)} couldn\'t be hashed properly. To enable hashing, specify \'con\' as URI string instead.'''	)
  
         return super().create_config_id(snake_case__   ,       custom_features=snake_case__	)
  
     @property
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	{
             '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 					snake_case_							(       datasets.ArrowBasedBuilder      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						SqlConfig
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[Any]	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         return datasets.DatasetInfo(features=self.config.features	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	int   ,       snake_case__:	Dict	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         return [datasets.SplitGenerator(name=datasets.Split.TRAIN   ,       gen_kwargs={}	)]
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]   ,       snake_case__:	pa.Table	)  ->		pa.Table:
  
  
         """simple docstring"""
  
  
  
         if self.config.features is not None:
             _lowercase     =	self.config.features.arrow_schema
             if all(not require_storage_cast(snake_case__	) for feature in self.config.features.values()	):
                 # cheaper cast
                 _lowercase     =	pa.Table.from_arrays([pa_table[field.name] for field in schema]   ,       schema=snake_case__	)
             else:
                 # more expensive cast; allows str <-> int/float or str to Audio for example
                 _lowercase     =	table_cast(snake_case__   ,       snake_case__	)
         return pa_table
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.config.chunksize
         _lowercase     =	pd.read_sql(
             self.config.sql   ,       self.config.con   ,       chunksize=snake_case__   ,       **self.config.pd_read_sql_kwargs	)
         _lowercase     =	[sql_reader] if chunksize is None else sql_reader
         for chunk_idx, df in enumerate(snake_case__	):
             _lowercase     =	pa.Table.from_pandas(snake_case__	)
             yield chunk_idx, self._cast_table(snake_case__	)
  
style_context: 
  
  
  
  
  
  
  from typing import Dict, List, Optional, Union
  
  import numpy as np
  
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
  from ...image_utils import (
      IMAGENET_STANDARD_MEAN,
      IMAGENET_STANDARD_STD,
      ChannelDimension,
      ImageInput,
      PILImageResampling,
      make_list_of_images,
      to_numpy_array,
      valid_images,
  )
  from ...utils import TensorType, is_vision_available, logging
  
  
  if is_vision_available():
     import PIL
  
  
  lowerCamelCase										=  logging.get_logger(__name__)
  
  class 					snake_case_							(       lowercase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						["""pixel_values"""]
  
     def __init__(    self:	int   ,       snake_case__:	bool = True   ,       snake_case__:	Dict[str, int] = None   ,       snake_case__:	PILImageResampling = PIL.Image.NEAREST   ,       snake_case__:	bool = False   ,       snake_case__:	Dict[str, int] = None   ,       snake_case__:	Union[int, float] = 1 / 255   ,       snake_case__:	bool = False   ,       snake_case__:	bool = True   ,       snake_case__:	bool = True   ,       snake_case__:	Optional[Union[float, List[float]]] = None   ,       snake_case__:	Optional[Union[float, List[float]]] = None   ,       snake_case__:	bool = True   ,       **snake_case__:	Optional[Any]   ,       )  ->		None:
  
  
         """simple docstring"""
  
  
  
         super().__init__(**snake_case__	)
         _lowercase     =	size if size is not None else {'height': 346, 'width': 346}
         _lowercase     =	get_size_dict(snake_case__	)
         _lowercase     =	crop_size if crop_size is not None else {'height': 289, 'width': 289}
         _lowercase     =	get_size_dict(snake_case__   ,       param_name='crop_size'	)
  
         _lowercase     =	do_resize
         _lowercase     =	size
         _lowercase     =	resample
         _lowercase     =	do_center_crop
         _lowercase     =	crop_size
         _lowercase     =	do_rescale
         _lowercase     =	rescale_factor
         _lowercase     =	rescale_offset
         _lowercase     =	do_normalize
         _lowercase     =	image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
         _lowercase     =	image_std if image_std is not None else IMAGENET_STANDARD_STD
         _lowercase     =	include_top
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	str   ,       snake_case__:	np.ndarray   ,       snake_case__:	Dict[str, int]   ,       snake_case__:	PILImageResampling = PIL.Image.NEAREST   ,       snake_case__:	Optional[Union[str, ChannelDimension]] = None   ,       **snake_case__:	Optional[int]   ,       )  ->		np.ndarray:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	get_size_dict(snake_case__	)
         if "height" not in size or "width" not in size:
             raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''	)
         return resize(
             snake_case__   ,       size=(size['height'], size['width'])   ,       resample=snake_case__   ,       data_format=snake_case__   ,       **snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]   ,       snake_case__:	np.ndarray   ,       snake_case__:	Dict[str, int]   ,       snake_case__:	Optional[Union[str, ChannelDimension]] = None   ,       **snake_case__:	str   ,       )  ->		np.ndarray:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	get_size_dict(snake_case__	)
         if "height" not in size or "width" not in size:
             raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''	)
         return center_crop(snake_case__   ,       size=(size['height'], size['width'])   ,       data_format=snake_case__   ,       **snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]   ,       snake_case__:	np.ndarray   ,       snake_case__:	Union[int, float]   ,       snake_case__:	bool = True   ,       snake_case__:	Optional[Union[str, ChannelDimension]] = None   ,       **snake_case__:	List[str]   ,       )  ->		Optional[int]:
  
  
         """simple docstring"""
  
  
  
         if offset:
             _lowercase     =	(image - 1_27.5) * scale
             if data_format is not None:
                 _lowercase     =	to_channel_dimension_format(snake_case__   ,       snake_case__	)
             _lowercase     =	rescaled_image.astype(np.floataa	)
         else:
             _lowercase     =	rescale(snake_case__   ,       scale=snake_case__   ,       data_format=snake_case__   ,       **snake_case__	)
         return rescaled_image
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict   ,       snake_case__:	np.ndarray   ,       snake_case__:	Union[float, List[float]]   ,       snake_case__:	Union[float, List[float]]   ,       snake_case__:	Optional[Union[str, ChannelDimension]] = None   ,       **snake_case__:	Any   ,       )  ->		np.ndarray:
  
  
         """simple docstring"""
  
  
  
         return normalize(snake_case__   ,       mean=snake_case__   ,       std=snake_case__   ,       data_format=snake_case__   ,       **snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]   ,       snake_case__:	ImageInput   ,       snake_case__:	bool = None   ,       snake_case__:	Dict[str, int] = None   ,       snake_case__:	Union[str, Any]=None   ,       snake_case__:	bool = None   ,       snake_case__:	Dict[str, int] = None   ,       snake_case__:	bool = None   ,       snake_case__:	float = None   ,       snake_case__:	bool = None   ,       snake_case__:	bool = None   ,       snake_case__:	Optional[Union[float, List[float]]] = None   ,       snake_case__:	Optional[Union[float, List[float]]] = None   ,       snake_case__:	bool = None   ,       snake_case__:	Optional[Union[str, TensorType]] = None   ,       snake_case__:	ChannelDimension = ChannelDimension.FIRST   ,       **snake_case__:	int   ,       )  ->		PIL.Image.Image:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	do_resize if do_resize is not None else self.do_resize
         _lowercase     =	resample if resample is not None else self.resample
         _lowercase     =	do_center_crop if do_center_crop is not None else self.do_center_crop
         _lowercase     =	do_rescale if do_rescale is not None else self.do_rescale
         _lowercase     =	rescale_factor if rescale_factor is not None else self.rescale_factor
         _lowercase     =	rescale_offset if rescale_offset is not None else self.rescale_offset
         _lowercase     =	do_normalize if do_normalize is not None else self.do_normalize
         _lowercase     =	image_mean if image_mean is not None else self.image_mean
         _lowercase     =	image_std if image_std is not None else self.image_std
         _lowercase     =	include_top if include_top is not None else self.include_top
  
         _lowercase     =	size if size is not None else self.size
         _lowercase     =	get_size_dict(snake_case__	)
         _lowercase     =	crop_size if crop_size is not None else self.crop_size
         _lowercase     =	get_size_dict(snake_case__   ,       param_name='crop_size'	)
  
         _lowercase     =	make_list_of_images(snake_case__	)
  
         if not valid_images(snake_case__	):
             raise ValueError(
                 'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
                 'torch.Tensor, tf.Tensor or jax.ndarray.'	)
  
         if do_resize and size is None or resample is None:
             raise ValueError('Size and resample must be specified if do_resize is True.'	)
  
         if do_center_crop and crop_size is None:
             raise ValueError('Crop size must be specified if do_center_crop is True.'	)
  
         if do_rescale and rescale_factor is None:
             raise ValueError('Rescale factor must be specified if do_rescale is True.'	)
  
         if do_normalize and (image_mean is None or image_std is None):
             raise ValueError('Image mean and std must be specified if do_normalize is True.'	)
  
         # All transformations expect numpy arrays.
         _lowercase     =	[to_numpy_array(snake_case__	) for image in images]
  
         if do_resize:
             _lowercase     =	[self.resize(image=snake_case__   ,       size=snake_case__   ,       resample=snake_case__	) for image in images]
  
         if do_center_crop:
             _lowercase     =	[self.center_crop(image=snake_case__   ,       size=snake_case__	) for image in images]
  
         if do_rescale:
             _lowercase     =	[self.rescale(image=snake_case__   ,       scale=snake_case__   ,       offset=snake_case__	) for image in images]
  
         if do_normalize:
             _lowercase     =	[self.normalize(image=snake_case__   ,       mean=snake_case__   ,       std=snake_case__	) for image in images]
  
         if include_top:
             _lowercase     =	[self.normalize(image=snake_case__   ,       mean=[0, 0, 0]   ,       std=snake_case__	) for image in images]
  
         _lowercase     =	[to_channel_dimension_format(snake_case__   ,       snake_case__	) for image in images]
  
         _lowercase     =	{'pixel_values': images}
         return BatchFeature(data=snake_case__   ,       tensor_type=snake_case__	)
  