

"""simple docstring"""






import importlib
import os
import platform
from pathlib import Path

from packaging import version

from .utils.logging import get_logger


__lowerCAmelCase				      =   get_logger(__name__)

# Datasets
__lowerCAmelCase				      =   '''https://s3.amazonaws.com/datasets.huggingface.co/datasets/datasets'''
__lowerCAmelCase				      =   '''https://cdn-datasets.huggingface.co/datasets/datasets'''
__lowerCAmelCase				      =   '''https://raw.githubusercontent.com/huggingface/datasets/{revision}/datasets/{path}/{name}'''

# Metrics
__lowerCAmelCase				      =   '''https://s3.amazonaws.com/datasets.huggingface.co/datasets/metrics'''
__lowerCAmelCase				      =   '''https://cdn-datasets.huggingface.co/datasets/metric'''
__lowerCAmelCase				      =   '''https://raw.githubusercontent.com/huggingface/datasets/{revision}/metrics/{path}/{name}'''

# Hub
__lowerCAmelCase				      =   os.environ.get('''HF_ENDPOINT''', '''https://huggingface.co''')
__lowerCAmelCase				      =   HF_ENDPOINT + '''/datasets/{repo_id}/resolve/{revision}/{path}'''
__lowerCAmelCase				      =   '''main'''

__lowerCAmelCase				      =   version.parse(platform.python_version())

if PY_VERSION < version.parse('''3.8'''):
							import importlib_metadata
else:
							import importlib.metadata as importlib_metadata

# General environment variables accepted values for booleans
__lowerCAmelCase				      =   {'''1''', '''ON''', '''YES''', '''TRUE'''}
__lowerCAmelCase				      =   ENV_VARS_TRUE_VALUES.union({'''AUTO'''})


# Imports
__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''dill'''))
__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''pandas'''))
__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''pyarrow'''))

__lowerCAmelCase				      =   os.environ.get('''USE_TF''', '''AUTO''').upper()
__lowerCAmelCase				      =   os.environ.get('''USE_TORCH''', '''AUTO''').upper()
__lowerCAmelCase				      =   os.environ.get('''USE_JAX''', '''AUTO''').upper()

__lowerCAmelCase				      =   '''N/A'''
__lowerCAmelCase				      =   False

if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES:
							__lowerCAmelCase				      =   importlib.util.find_spec('''torch''') is not None
							if TORCH_AVAILABLE:
														try:
																					__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''torch'''))
																					logger.info(f'''PyTorch version {TORCH_VERSION} available.''')
														except importlib_metadata.PackageNotFoundError:
																					pass
else:
							logger.info('''Disabling PyTorch because USE_TF is set''')

__lowerCAmelCase				      =   '''N/A'''
__lowerCAmelCase				      =   False

if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VALUES:
							__lowerCAmelCase				      =   importlib.util.find_spec('''tensorflow''') is not None
							if TF_AVAILABLE:
														# For the metadata, we have to look for both tensorflow and tensorflow-cpu
														for package in [
														    "tensorflow",
														    "tensorflow-cpu",
														    "tensorflow-gpu",
														    "tf-nightly",
														    "tf-nightly-cpu",
														    "tf-nightly-gpu",
														    "intel-tensorflow",
														    "tensorflow-rocm",
														    "tensorflow-macos",
														]:
																					try:
																												__lowerCAmelCase				      =   version.parse(importlib_metadata.version(package))
																					except importlib_metadata.PackageNotFoundError:
																												continue
																					else:
																												break
														else:
																					__lowerCAmelCase				      =   False
							if TF_AVAILABLE:
														if TF_VERSION.major < 2:
																					logger.info(f'''TensorFlow found but with version {TF_VERSION}. `datasets` requires version 2 minimum.''')
																					__lowerCAmelCase				      =   False
														else:
																					logger.info(f'''TensorFlow version {TF_VERSION} available.''')
else:
							logger.info('''Disabling Tensorflow because USE_TORCH is set''')


__lowerCAmelCase				      =   '''N/A'''
__lowerCAmelCase				      =   False

if USE_JAX in ENV_VARS_TRUE_AND_AUTO_VALUES:
							__lowerCAmelCase				      =   importlib.util.find_spec('''jax''') is not None and importlib.util.find_spec('''jaxlib''') is not None
							if JAX_AVAILABLE:
														try:
																					__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''jax'''))
																					logger.info(f'''JAX version {JAX_VERSION} available.''')
														except importlib_metadata.PackageNotFoundError:
																					pass
else:
							logger.info('''Disabling JAX because USE_JAX is set to False''')


__lowerCAmelCase				      =   os.environ.get('''USE_BEAM''', '''AUTO''').upper()
__lowerCAmelCase				      =   '''N/A'''
__lowerCAmelCase				      =   False
if USE_BEAM in ENV_VARS_TRUE_AND_AUTO_VALUES:
							try:
														__lowerCAmelCase				      =   version.parse(importlib_metadata.version('''apache_beam'''))
														__lowerCAmelCase				      =   True
														logger.info(f'''Apache Beam version {BEAM_VERSION} available.''')
							except importlib_metadata.PackageNotFoundError:
														pass
else:
							logger.info('''Disabling Apache Beam because USE_BEAM is set to False''')


# Optional tools for data loading
__lowerCAmelCase				      =   importlib.util.find_spec('''sqlalchemy''') is not None

# Optional tools for feature decoding
__lowerCAmelCase				      =   importlib.util.find_spec('''PIL''') is not None
__lowerCAmelCase				      =   importlib.util.find_spec('''soundfile''') is not None and version.parse(
    importlib.import_module('''soundfile''').__libsndfile_version__
) >= version.parse('''1.0.31''')
__lowerCAmelCase				      =   importlib.util.find_spec('''soundfile''') is not None and version.parse(
    importlib.import_module('''soundfile''').__libsndfile_version__
) >= version.parse('''1.1.0''')

# Optional compression tools
__lowerCAmelCase				      =   importlib.util.find_spec('''rarfile''') is not None
__lowerCAmelCase				      =   importlib.util.find_spec('''zstandard''') is not None
__lowerCAmelCase				      =   importlib.util.find_spec('''lz4''') is not None
__lowerCAmelCase				      =   importlib.util.find_spec('''py7zr''') is not None


# Cache location
__lowerCAmelCase				      =   '''~/.cache'''
__lowerCAmelCase				      =   os.getenv('''XDG_CACHE_HOME''', DEFAULT_XDG_CACHE_HOME)
__lowerCAmelCase				      =   os.path.join(XDG_CACHE_HOME, '''huggingface''')
__lowerCAmelCase				      =   os.path.expanduser(os.getenv('''HF_HOME''', DEFAULT_HF_CACHE_HOME))

__lowerCAmelCase				      =   os.path.join(HF_CACHE_HOME, '''datasets''')
__lowerCAmelCase				      =   Path(os.getenv('''HF_DATASETS_CACHE''', DEFAULT_HF_DATASETS_CACHE))

__lowerCAmelCase				      =   os.path.join(HF_CACHE_HOME, '''metrics''')
__lowerCAmelCase				      =   Path(os.getenv('''HF_METRICS_CACHE''', DEFAULT_HF_METRICS_CACHE))

__lowerCAmelCase				      =   os.path.join(HF_CACHE_HOME, '''modules''')
__lowerCAmelCase				      =   Path(os.getenv('''HF_MODULES_CACHE''', DEFAULT_HF_MODULES_CACHE))

__lowerCAmelCase				      =   '''downloads'''
__lowerCAmelCase				      =   os.path.join(HF_DATASETS_CACHE, DOWNLOADED_DATASETS_DIR)
__lowerCAmelCase				      =   Path(os.getenv('''HF_DATASETS_DOWNLOADED_DATASETS_PATH''', DEFAULT_DOWNLOADED_DATASETS_PATH))

__lowerCAmelCase				      =   '''extracted'''
__lowerCAmelCase				      =   os.path.join(DEFAULT_DOWNLOADED_DATASETS_PATH, EXTRACTED_DATASETS_DIR)
__lowerCAmelCase				      =   Path(os.getenv('''HF_DATASETS_EXTRACTED_DATASETS_PATH''', DEFAULT_EXTRACTED_DATASETS_PATH))

# Download count for the website
__lowerCAmelCase				      =   (
    os.environ.get('''HF_UPDATE_DOWNLOAD_COUNTS''', '''AUTO''').upper() in ENV_VARS_TRUE_AND_AUTO_VALUES
)

# Batch size constants. For more info, see:
# https://github.com/apache/arrow/blob/master/docs/source/cpp/arrays.rst#size-limitations-and-recommendations)
__lowerCAmelCase				      =   1_000

# Size of the preloaded record batch in `Dataset.__iter__`
__lowerCAmelCase				      =   10

# Pickling tables works only for small tables (<4GiB)
# For big tables, we write them on disk instead
__lowerCAmelCase				      =   4 << 30

# Max shard size in bytes (e.g. to shard parquet datasets in push_to_hub or download_and_prepare)
__lowerCAmelCase				      =   '''500MB'''

# Parquet configuration
__lowerCAmelCase				      =   100
__lowerCAmelCase				      =   100
__lowerCAmelCase				      =   100

# Offline mode
__lowerCAmelCase				      =   os.environ.get('''HF_DATASETS_OFFLINE''', '''AUTO''').upper() in ENV_VARS_TRUE_VALUES

# In-memory
__lowerCAmelCase				      =   0  # Disabled
__lowerCAmelCase				      =   float(os.environ.get('''HF_DATASETS_IN_MEMORY_MAX_SIZE''', DEFAULT_IN_MEMORY_MAX_SIZE))

# File names
__lowerCAmelCase				      =   '''dataset.arrow'''
__lowerCAmelCase				      =   '''indices.arrow'''
__lowerCAmelCase				      =   '''state.json'''
__lowerCAmelCase				      =   '''dataset_info.json'''
__lowerCAmelCase				      =   '''dataset_infos.json'''
__lowerCAmelCase				      =   '''LICENSE'''
__lowerCAmelCase				      =   '''metric_info.json'''
__lowerCAmelCase				      =   '''dataset_dict.json'''

__lowerCAmelCase				      =   '''datasets_modules'''

__lowerCAmelCase				      =   255

# Streaming
__lowerCAmelCase				      =   20
__lowerCAmelCase				      =   5

# Datasets without script
__lowerCAmelCase				      =   200
__lowerCAmelCase				      =   10
__lowerCAmelCase				      =   200

# Progress bars
__lowerCAmelCase				      =   0.05  # 20 progress updates per sec


"""simple docstring"""






def 		A_	(   __UpperCamelCase     :				str       ,	__UpperCamelCase     :				str				):
		if not isinstance(__UpperCamelCase       ,	__UpperCamelCase				):
				raise TypeError('''plaintext must be a string'''				)
		if not isinstance(__UpperCamelCase       ,	__UpperCamelCase				):
				raise TypeError('''key must be a string'''				)

		if not plaintext:
				raise ValueError('''plaintext is empty'''				)
		if not key:
				raise ValueError('''key is empty'''				)

		key += plaintext
		lowercase										=							plaintext.lower()
		lowercase										=							key.lower()
		lowercase										=							0
		lowercase										=							0
		lowercase										=							''''''
		while plaintext_iterator < len(__UpperCamelCase				):
				if (
				    ord(plaintext[plaintext_iterator]				) < 97
				    or ord(plaintext[plaintext_iterator]				) > 1_22
				):
						ciphertext += plaintext[plaintext_iterator]
						plaintext_iterator += 1
				elif ord(key[key_iterator]				) < 97 or ord(key[key_iterator]				) > 1_22:
						key_iterator += 1
				else:
						ciphertext += chr(
						    (
						        (ord(plaintext[plaintext_iterator]				) - 97 + ord(key[key_iterator]				))
						        - 97
						    )
						    % 26
						    + 97				)
						key_iterator += 1
						plaintext_iterator += 1
		return ciphertext
def 		A_	(   __UpperCamelCase     :				str       ,	__UpperCamelCase     :				str				):
		if not isinstance(__UpperCamelCase       ,	__UpperCamelCase				):
				raise TypeError('''ciphertext must be a string'''				)
		if not isinstance(__UpperCamelCase       ,	__UpperCamelCase				):
				raise TypeError('''key must be a string'''				)

		if not ciphertext:
				raise ValueError('''ciphertext is empty'''				)
		if not key:
				raise ValueError('''key is empty'''				)

		lowercase										=							key.lower()
		lowercase										=							0
		lowercase										=							0
		lowercase										=							''''''
		while ciphertext_iterator < len(__UpperCamelCase				):
				if (
				    ord(ciphertext[ciphertext_iterator]				) < 97
				    or ord(ciphertext[ciphertext_iterator]				) > 1_22
				):
						plaintext += ciphertext[ciphertext_iterator]
				else:
						plaintext += chr(
						    (ord(ciphertext[ciphertext_iterator]				) - ord(key[key_iterator]				)) % 26
						    + 97				)
						key += chr(
						    (ord(ciphertext[ciphertext_iterator]				) - ord(key[key_iterator]				)) % 26
						    + 97				)
						key_iterator += 1
				ciphertext_iterator += 1
		return plaintext


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							__lowerCAmelCase				      =   int(input('''Type 1 to encrypt or 2 to decrypt:'''))
							if operation == 1:
														__lowerCAmelCase				      =   input('''Typeplaintext to be encrypted:\n''')
														__lowerCAmelCase				      =   input('''Type the key:\n''')
														print(encrypt(plaintext, key))
							elif operation == 2:
														__lowerCAmelCase				      =   input('''Type the ciphertext to be decrypted:\n''')
														__lowerCAmelCase				      =   input('''Type the key:\n''')
														print(decrypt(ciphertext, key))
							decrypt('''jsqqs avvwo''', '''coffee''')