
SCREAMING_SNAKE_CASE__   :			List[Any]												=    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"




def  __magic_name__ (   __lowerCAmelCase	:						bytes							)			->   bytes:
				# Make sure the supplied data is a bytes-like object
				if not isinstance(__lowerCAmelCase		,  __lowerCAmelCase							):
								__lowerCamelCase    					=	f'''a bytes-like object is required, not \'{data.__class__.__name__}\''''
								raise TypeError(__lowerCAmelCase							)

				__lowerCamelCase    					=	''''''.join(bin(__lowerCAmelCase							)[2:].zfill(8							) for byte in data							)

				__lowerCamelCase    					=	len(__lowerCAmelCase							) % 6 != 0

				if padding_needed:
								# The padding that will be added later
								__lowerCamelCase    					=	B'''=''' * ((6 - len(__lowerCAmelCase							) % 6) // 2)

								# Append binary_stream with arbitrary binary digits (0's by default) to make its
								# length a multiple of 6.
								binary_stream += "0" * (6 - len(__lowerCAmelCase							) % 6)
				else:
								__lowerCamelCase    					=	B''''''

				# Encode every 6 binary digits to their corresponding Base64 character
				return (
				    "".join(
				        B64_CHARSET[int(binary_stream[index : index + 6]		,  2							)]
				        for index in range(0		,  len(__lowerCAmelCase							)		,  6							)							).encode()
				    + padding
				)




def  __magic_name__ (   __lowerCAmelCase	:						str							)			->   bytes:
				# Make sure encoded_data is either a string or a bytes-like object
				if not isinstance(__lowerCAmelCase		,  __lowerCAmelCase							) and not isinstance(__lowerCAmelCase		,  __lowerCAmelCase							):
								__lowerCamelCase    					=	(
								    '''argument should be a bytes-like object or ASCII string, '''
								    f'''not \'{encoded_data.__class__.__name__}\''''
								)
								raise TypeError(__lowerCAmelCase							)

				# In case encoded_data is a bytes-like object, make sure it contains only
				# ASCII characters so we convert it to a string object
				if isinstance(__lowerCAmelCase		,  __lowerCAmelCase							):
								try:
												__lowerCamelCase    					=	encoded_data.decode('''utf-8'''							)
								except UnicodeDecodeError:
												raise ValueError('''base64 encoded data should only contain ASCII characters'''							)

				__lowerCamelCase    					=	encoded_data.count('''='''							)

				# Check if the encoded string contains non base64 characters
				if padding:
								assert all(
								    char in B64_CHARSET for char in encoded_data[:-padding]							), "Invalid base64 character(s) found."
				else:
								assert all(
								    char in B64_CHARSET for char in encoded_data							), "Invalid base64 character(s) found."

				# Check the padding
				assert len(__lowerCAmelCase							) % 4 == 0 and padding < 3, "Incorrect padding"

				if padding:
								# Remove padding if there is one
								__lowerCamelCase    					=	encoded_data[:-padding]

								__lowerCamelCase    					=	''''''.join(
								    bin(B64_CHARSET.index(__lowerCAmelCase							)							)[2:].zfill(6							) for char in encoded_data							)[: -padding * 2]
				else:
								__lowerCamelCase    					=	''''''.join(
								    bin(B64_CHARSET.index(__lowerCAmelCase							)							)[2:].zfill(6							) for char in encoded_data							)

				__lowerCamelCase    					=	[
				    int(binary_stream[index : index + 8]		,  2							)
				    for index in range(0		,  len(__lowerCAmelCase							)		,  8							)
				]

				return bytes(__lowerCAmelCase							)


if __name__ == "__main__":
					import doctest

					doctest.testmod()





from typing import Optional

from .. import Features, NamedSplit
from ..packaged_modules.text.text import Text
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader

class    lowerCAmelCase__     (	__lowercase			):






		def __init__(		self		:							Tuple							,			SCREAMING_SNAKE_CASE__		:							NestedDataStructureLike[PathLike]							,			SCREAMING_SNAKE_CASE__		:							Optional[NamedSplit] = None							,			SCREAMING_SNAKE_CASE__		:							Optional[Features] = None							,			SCREAMING_SNAKE_CASE__		:							str = None							,			SCREAMING_SNAKE_CASE__		:							bool = False							,			SCREAMING_SNAKE_CASE__		:							bool = False							,			SCREAMING_SNAKE_CASE__		:							Optional[int] = None							,			**SCREAMING_SNAKE_CASE__		:							str							,			)     ->							Union[str, Any]:
						super().__init__(
						    SCREAMING_SNAKE_CASE__							,			split=SCREAMING_SNAKE_CASE__							,			features=SCREAMING_SNAKE_CASE__							,			cache_dir=SCREAMING_SNAKE_CASE__							,			keep_in_memory=SCREAMING_SNAKE_CASE__							,			streaming=SCREAMING_SNAKE_CASE__							,			num_proc=SCREAMING_SNAKE_CASE__							,			**SCREAMING_SNAKE_CASE__							,			)
						__lowerCamelCase    					=	path_or_paths if isinstance(SCREAMING_SNAKE_CASE__							,			SCREAMING_SNAKE_CASE__  ) else {self.split: path_or_paths}
						__lowerCamelCase    					=	Text(
						    cache_dir=SCREAMING_SNAKE_CASE__							,			data_files=SCREAMING_SNAKE_CASE__							,			features=SCREAMING_SNAKE_CASE__							,			**SCREAMING_SNAKE_CASE__							,			)







		def  __A       (		self		:							int  )     ->							Dict:
						# Build iterable dataset
						if self.streaming:
										__lowerCamelCase    					=	self.builder.as_streaming_dataset(split=self.split  )
						# Build regular (map-style) dataset
						else:
										__lowerCamelCase    					=	None
										__lowerCamelCase    					=	None
										__lowerCamelCase    					=	None
										__lowerCamelCase    					=	None

										self.builder.download_and_prepare(
										    download_config=SCREAMING_SNAKE_CASE__							,			download_mode=SCREAMING_SNAKE_CASE__							,			verification_mode=SCREAMING_SNAKE_CASE__							,			base_path=SCREAMING_SNAKE_CASE__							,			num_proc=self.num_proc							,			)
										__lowerCamelCase    					=	self.builder.as_dataset(
										    split=self.split							,			verification_mode=SCREAMING_SNAKE_CASE__							,			in_memory=self.keep_in_memory  )
						return dataset



