




import math
from collections import defaultdict
from typing import List, Optional, Tuple, Union

import numpy as np
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import randn_tensor
from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput







def 			lowerCAmelCase  (     UpperCAmelCase,     UpperCAmelCase=0.9_99,     UpperCAmelCase="cosine",     )  ->Optional[Any]:






					"""simple docstring"""






					if alpha_transform_type == "cosine":

										def alpha_bar_fn(UpperCAmelCase	):
															return math.cos((t + 0.0_08) / 1.0_08 * math.pi / 2	) ** 2

					elif alpha_transform_type == "exp":

										def alpha_bar_fn(UpperCAmelCase	):
															return math.exp(t * -12.0	)

					else:
										raise ValueError(F'''Unsupported alpha_tranform_type: {alpha_transform_type}'''	)

					__magic_name__ :							Dict		       =							[]
					for i in range(UpperCAmelCase	):
										__magic_name__ :							Any		       =							i / num_diffusion_timesteps
										__magic_name__ :							int		       =							(i + 1) / num_diffusion_timesteps
										betas.append(min(1 - alpha_bar_fn(UpperCAmelCase	) / alpha_bar_fn(UpperCAmelCase	),     UpperCAmelCase	)	)
					return torch.tensor(UpperCAmelCase,     dtype=torch.floataa	)





class 		A__    (       __SCREAMING_SNAKE_CASE		,					__SCREAMING_SNAKE_CASE			):
	lowerCamelCase__		:			Optional[int]       =[e.name for e in KarrasDiffusionSchedulers]
	lowerCamelCase__		:			int       =2






	@register_to_config
	def __init__(     self    ,					lowerCamelCase = 1000    ,					lowerCamelCase = 0.0_0_0_8_5    ,					lowerCamelCase = 0.0_1_2    ,					lowerCamelCase = "linear"    ,					lowerCamelCase = None    ,					lowerCamelCase = "epsilon"    ,					lowerCamelCase = "linspace"    ,					lowerCamelCase = 0    ,					)				->       Dict:




						"""simple docstring"""






						if trained_betas is not None:
											__magic_name__ :							Union[str, Any]		       =							torch.tensor(lowerCamelCase    ,					dtype=torch.floataa						)
						elif beta_schedule == "linear":
											__magic_name__ :							List[Any]		       =							torch.linspace(lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					dtype=torch.floataa						)
						elif beta_schedule == "scaled_linear":
											# this schedule is very specific to the latent diffusion model.
											__magic_name__ :							Optional[int]		       =							(
											    torch.linspace(beta_start**0.5    ,					beta_end**0.5    ,					lowerCamelCase    ,					dtype=torch.floataa						) ** 2
											)
						elif beta_schedule == "squaredcos_cap_v2":
											# Glide cosine schedule
											__magic_name__ :							List[str]		       =							betas_for_alpha_bar(lowerCamelCase						)
						else:
											raise NotImplementedError(F'''{beta_schedule} does is not implemented for {self.__class__}'''						)

						__magic_name__ :							Any		       =							1.0 - self.betas
						__magic_name__ :							Optional[Any]		       =							torch.cumprod(self.alphas    ,					dim=0						)

						#  set all values
						self.set_timesteps(lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase						)






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase=None						)				->       Optional[Any]:




						"""simple docstring"""






						if schedule_timesteps is None:
											__magic_name__ :							Union[str, Any]		       =							self.timesteps

						__magic_name__ :							str		       =							(schedule_timesteps == timestep).nonzero()

						# The sigma index that is taken for the **very** first `step`
						# is always the second index (or the last index if there is only 1)
						# This way we can ensure we don't accidentally skip a sigma in
						# case we start in the middle of the denoising schedule (e.g. for image-to-image)
						if len(self._index_counter						) == 0:
											__magic_name__ :							str		       =							1 if len(lowerCamelCase						) > 1 else 0
						else:
											__magic_name__ :							str		       =							timestep.cpu().item() if torch.is_tensor(lowerCamelCase						) else timestep
											__magic_name__ :							Tuple		       =							self._index_counter[timestep_int]

						return indices[pos].item()






	@property
	def 			lowercase				(     self						)				->       int:




						"""simple docstring"""






						if self.config.timestep_spacing in ["linspace", "trailing"]:
											return self.sigmas.max()

						return (self.sigmas.max() ** 2 + 1) ** 0.5






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase    ,					)				->       torch.FloatTensor:




						"""simple docstring"""






						__magic_name__ :							Any		       =							self.index_for_timestep(lowerCamelCase						)

						if self.state_in_first_order:
											__magic_name__ :							Optional[Any]		       =							self.sigmas[step_index]
						else:
											__magic_name__ :							List[Any]		       =							self.sigmas_interpol[step_index - 1]

						__magic_name__ :							Dict		       =							sample / ((sigma**2 + 1) ** 0.5)
						return sample






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase = None    ,					lowerCamelCase = None    ,					)				->       Optional[int]:




						"""simple docstring"""






						__magic_name__ :							List[Any]		       =							num_inference_steps

						__magic_name__ :							Optional[Any]		       =							num_train_timesteps or self.config.num_train_timesteps

						# "linspace", "leading", "trailing" corresponds to annotation of Table 2. of https://arxiv.org/abs/2305.08891
						if self.config.timestep_spacing == "linspace":
											__magic_name__ :							int		       =							np.linspace(0    ,					num_train_timesteps - 1    ,					lowerCamelCase    ,					dtype=lowerCamelCase						)[::-1].copy()
						elif self.config.timestep_spacing == "leading":
											__magic_name__ :							Union[str, Any]		       =							num_train_timesteps // self.num_inference_steps
											# creates integer timesteps by multiplying by ratio
											# casting to int to avoid issues when num_inference_step is power of 3
											__magic_name__ :							Tuple		       =							(np.arange(0    ,					lowerCamelCase						) * step_ratio).round()[::-1].copy().astype(lowerCamelCase						)
											timesteps += self.config.steps_offset
						elif self.config.timestep_spacing == "trailing":
											__magic_name__ :							Any		       =							num_train_timesteps / self.num_inference_steps
											# creates integer timesteps by multiplying by ratio
											# casting to int to avoid issues when num_inference_step is power of 3
											__magic_name__ :							Dict		       =							(np.arange(lowerCamelCase    ,					0    ,					-step_ratio						)).round().copy().astype(lowerCamelCase						)
											timesteps -= 1
						else:
											raise ValueError(
											    F'''{self.config.timestep_spacing} is not supported. Please make sure to choose one of \'linspace\', \'leading\' or \'trailing\'.'''						)

						__magic_name__ :							Dict		       =							np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5						)
						__magic_name__ :							str		       =							torch.from_numpy(np.log(lowerCamelCase						)						).to(lowerCamelCase						)

						__magic_name__ :							List[Any]		       =							np.interp(lowerCamelCase    ,					np.arange(0    ,					len(lowerCamelCase						)						)    ,					lowerCamelCase						)
						__magic_name__ :							Optional[int]		       =							np.concatenate([sigmas, [0.0]]						).astype(np.floataa						)
						__magic_name__ :							List[str]		       =							torch.from_numpy(lowerCamelCase						).to(device=lowerCamelCase						)

						# compute up and down sigmas
						__magic_name__ :							Optional[int]		       =							sigmas.roll(-1						)
						__magic_name__ :							str		       =							0.0
						__magic_name__ :							Optional[int]		       =							(sigmas_next**2 * (sigmas**2 - sigmas_next**2) / sigmas**2) ** 0.5
						__magic_name__ :							Union[str, Any]		       =							(sigmas_next**2 - sigmas_up**2) ** 0.5
						__magic_name__ :							Dict		       =							0.0

						# compute interpolated sigmas
						__magic_name__ :							int		       =							sigmas.log().lerp(sigmas_down.log()    ,					0.5						).exp()
						__magic_name__ :							int		       =							0.0

						# set sigmas
						__magic_name__ :							Any		       =							torch.cat([sigmas[:1], sigmas[1:].repeat_interleave(2						), sigmas[-1:]]						)
						__magic_name__ :							str		       =							torch.cat(
						    [sigmas_interpol[:1], sigmas_interpol[1:].repeat_interleave(2						), sigmas_interpol[-1:]]						)
						__magic_name__ :							Dict		       =							torch.cat([sigmas_up[:1], sigmas_up[1:].repeat_interleave(2						), sigmas_up[-1:]]						)
						__magic_name__ :							Optional[int]		       =							torch.cat([sigmas_down[:1], sigmas_down[1:].repeat_interleave(2						), sigmas_down[-1:]]						)

						if str(lowerCamelCase						).startswith('''mps'''						):
											# mps does not support float64
											__magic_name__ :							Any		       =							torch.from_numpy(lowerCamelCase						).to(lowerCamelCase    ,					dtype=torch.floataa						)
						else:
											__magic_name__ :							List[Any]		       =							torch.from_numpy(lowerCamelCase						).to(lowerCamelCase						)

						__magic_name__ :							Dict		       =							self.sigma_to_t(lowerCamelCase						).to(lowerCamelCase    ,					dtype=timesteps.dtype						)
						__magic_name__ :							Dict		       =							torch.stack((timesteps_interpol[:-2, None], timesteps[1:, None])    ,					dim=-1						).flatten()

						__magic_name__ :							List[str]		       =							torch.cat([timesteps[:1], interleaved_timesteps]						)

						__magic_name__ :							Union[str, Any]		       =							None

						# for exp beta schedules, such as the one for `pipeline_shap_e.py`
						# we need an index counter
						__magic_name__ :							Optional[Any]		       =							defaultdict(lowerCamelCase						)






	def 			lowercase				(     self    ,					lowerCamelCase						)				->       str:




						"""simple docstring"""






						__magic_name__ :							List[str]		       =							sigma.log()

						# get distribution
						__magic_name__ :							Tuple		       =							log_sigma - self.log_sigmas[:, None]

						# get sigmas range
						__magic_name__ :							Optional[Any]		       =							dists.ge(0						).cumsum(dim=0						).argmax(dim=0						).clamp(max=self.log_sigmas.shape[0] - 2						)
						__magic_name__ :							Tuple		       =							low_idx + 1

						__magic_name__ :							Any		       =							self.log_sigmas[low_idx]
						__magic_name__ :							str		       =							self.log_sigmas[high_idx]

						# interpolate sigmas
						__magic_name__ :							Dict		       =							(low - log_sigma) / (low - high)
						__magic_name__ :							int		       =							w.clamp(0    ,					1						)

						# transform interpolation to time range
						__magic_name__ :							List[str]		       =							(1 - w) * low_idx + w * high_idx
						__magic_name__ :							List[str]		       =							t.view(sigma.shape						)
						return t






	@property
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						return self.sample is None






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase = None    ,					lowerCamelCase = True    ,					)				->       Union[SchedulerOutput, Tuple]:




						"""simple docstring"""






						__magic_name__ :							Dict		       =							self.index_for_timestep(lowerCamelCase						)

						# advance index counter by 1
						__magic_name__ :							List[str]		       =							timestep.cpu().item() if torch.is_tensor(lowerCamelCase						) else timestep
						self._index_counter[timestep_int] += 1

						if self.state_in_first_order:
											__magic_name__ :							List[str]		       =							self.sigmas[step_index]
											__magic_name__ :							List[Any]		       =							self.sigmas_interpol[step_index]
											__magic_name__ :							int		       =							self.sigmas_up[step_index]
											__magic_name__ :							Optional[Any]		       =							self.sigmas_down[step_index - 1]
						else:
											# 2nd order / KPDM2's method
											__magic_name__ :							Union[str, Any]		       =							self.sigmas[step_index - 1]
											__magic_name__ :							Tuple		       =							self.sigmas_interpol[step_index - 1]
											__magic_name__ :							Optional[Any]		       =							self.sigmas_up[step_index - 1]
											__magic_name__ :							Optional[Any]		       =							self.sigmas_down[step_index - 1]

						# currently only gamma=0 is supported. This usually works best anyways.
						# We can support gamma in the future but then need to scale the timestep before
						# passing it to the model which requires a change in API
						__magic_name__ :							Tuple		       =							0
						__magic_name__ :							Dict		       =							sigma * (gamma + 1)  # Note: sigma_hat == sigma for now

						__magic_name__ :							Tuple		       =							model_output.device
						__magic_name__ :							str		       =							randn_tensor(model_output.shape    ,					dtype=model_output.dtype    ,					device=lowerCamelCase    ,					generator=lowerCamelCase						)

						# 1. compute predicted original sample (x_0) from sigma-scaled predicted noise
						if self.config.prediction_type == "epsilon":
											__magic_name__ :							Dict		       =							sigma_hat if self.state_in_first_order else sigma_interpol
											__magic_name__ :							int		       =							sample - sigma_input * model_output
						elif self.config.prediction_type == "v_prediction":
											__magic_name__ :							int		       =							sigma_hat if self.state_in_first_order else sigma_interpol
											__magic_name__ :							int		       =							model_output * (-sigma_input / (sigma_input**2 + 1) ** 0.5) + (
											    sample / (sigma_input**2 + 1)
											)
						elif self.config.prediction_type == "sample":
											raise NotImplementedError('''prediction_type not implemented yet: sample'''						)
						else:
											raise ValueError(
											    F'''prediction_type given as {self.config.prediction_type} must be one of `epsilon`, or `v_prediction`'''						)

						if self.state_in_first_order:
											# 2. Convert to an ODE derivative for 1st order
											__magic_name__ :							Optional[Any]		       =							(sample - pred_original_sample) / sigma_hat
											# 3. delta timestep
											__magic_name__ :							Optional[int]		       =							sigma_interpol - sigma_hat

											# store for 2nd order step
											__magic_name__ :							Union[str, Any]		       =							sample
											__magic_name__ :							List[str]		       =							dt
											__magic_name__ :							int		       =							sample + derivative * dt
						else:
											# DPM-Solver-2
											# 2. Convert to an ODE derivative for 2nd order
											__magic_name__ :							Dict		       =							(sample - pred_original_sample) / sigma_interpol
											# 3. delta timestep
											__magic_name__ :							Optional[Any]		       =							sigma_down - sigma_hat

											__magic_name__ :							str		       =							self.sample
											__magic_name__ :							str		       =							None

											__magic_name__ :							Tuple		       =							sample + derivative * dt
											__magic_name__ :							List[str]		       =							prev_sample + noise * sigma_up

						if not return_dict:
											return (prev_sample,)

						return SchedulerOutput(prev_sample=lowerCamelCase						)






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					)				->       torch.FloatTensor:




						"""simple docstring"""






						__magic_name__ :							str		       =							self.sigmas.to(device=original_samples.device    ,					dtype=original_samples.dtype						)
						if original_samples.device.type == "mps" and torch.is_floating_point(lowerCamelCase						):
											# mps does not support float64
											__magic_name__ :							int		       =							self.timesteps.to(original_samples.device    ,					dtype=torch.floataa						)
											__magic_name__ :							Tuple		       =							timesteps.to(original_samples.device    ,					dtype=torch.floataa						)
						else:
											__magic_name__ :							str		       =							self.timesteps.to(original_samples.device						)
											__magic_name__ :							List[Any]		       =							timesteps.to(original_samples.device						)

						__magic_name__ :							Tuple		       =							[self.index_for_timestep(lowerCamelCase    ,					lowerCamelCase						) for t in timesteps]

						__magic_name__ :							Dict		       =							sigmas[step_indices].flatten()
						while len(sigma.shape						) < len(original_samples.shape						):
											__magic_name__ :							Tuple		       =							sigma.unsqueeze(-1						)

						__magic_name__ :							List[Any]		       =							original_samples + noise * sigma
						return noisy_samples






	def __len__(     self						)				->       Dict:




						"""simple docstring"""






						return self.config.num_train_timesteps









import importlib
import os
import platform
from pathlib import Path

from packaging import version

from .utils.logging import get_logger


lowercase_		=							get_logger(__name__)

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

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

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

lowercase_		=							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
lowercase_		=							{'''1''', '''ON''', '''YES''', '''TRUE'''}
lowercase_		=							ENV_VARS_TRUE_VALUES.union({'''AUTO'''})


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

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

lowercase_		=							'''N/A'''
lowercase_		=							False

if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES:
				lowercase_		=							importlib.util.find_spec('''torch''') is not None
				if TORCH_AVAILABLE:
								try:
												lowercase_		=							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''')

lowercase_		=							'''N/A'''
lowercase_		=							False

if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VALUES:
				lowercase_		=							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:
																lowercase_		=							version.parse(importlib_metadata.version(package))
												except importlib_metadata.PackageNotFoundError:
																continue
												else:
																break
								else:
												lowercase_		=							False
				if TF_AVAILABLE:
								if TF_VERSION.major < 2:
												logger.info(f"TensorFlow found but with version {TF_VERSION}. `datasets` requires version 2 minimum.")
												lowercase_		=							False
								else:
												logger.info(f"TensorFlow version {TF_VERSION} available.")
else:
				logger.info('''Disabling Tensorflow because USE_TORCH is set''')


lowercase_		=							'''N/A'''
lowercase_		=							False

if USE_JAX in ENV_VARS_TRUE_AND_AUTO_VALUES:
				lowercase_		=							importlib.util.find_spec('''jax''') is not None and importlib.util.find_spec('''jaxlib''') is not None
				if JAX_AVAILABLE:
								try:
												lowercase_		=							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''')


lowercase_		=							os.environ.get('''USE_BEAM''', '''AUTO''').upper()
lowercase_		=							'''N/A'''
lowercase_		=							False
if USE_BEAM in ENV_VARS_TRUE_AND_AUTO_VALUES:
				try:
								lowercase_		=							version.parse(importlib_metadata.version('''apache_beam'''))
								lowercase_		=							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
lowercase_		=							importlib.util.find_spec('''sqlalchemy''') is not None

# Optional tools for feature decoding
lowercase_		=							importlib.util.find_spec('''PIL''') is not None
lowercase_		=							importlib.util.find_spec('''soundfile''') is not None and version.parse(
    importlib.import_module('''soundfile''').__libsndfile_version__
) >= version.parse('''1.0.31''')
lowercase_		=							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
lowercase_		=							importlib.util.find_spec('''rarfile''') is not None
lowercase_		=							importlib.util.find_spec('''zstandard''') is not None
lowercase_		=							importlib.util.find_spec('''lz4''') is not None
lowercase_		=							importlib.util.find_spec('''py7zr''') is not None


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

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

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

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

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

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

# Download count for the website
lowercase_		=							(
    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)
lowercase_		=							1000

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

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

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

# Parquet configuration
lowercase_		=							100
lowercase_		=							100
lowercase_		=							100

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

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

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

lowercase_		=							'''datasets_modules'''

lowercase_		=							255

# Streaming
lowercase_		=							20
lowercase_		=							5

# Datasets without script
lowercase_		=							200
lowercase_		=							10
lowercase_		=							200

# Progress bars
lowercase_		=							0.0_5  # 20 progress updates per sec



