
"""simple docstring"""





import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
    import jax
    import jax.numpy as jnp

    from transformers.modeling_flax_pytorch_utils import (
        convert_pytorch_state_dict_to_flax,
        load_flax_weights_in_pytorch_model,
    )
    from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
    import torch


class A_      :




  '''simple docstring'''







  def __init__(						self							,  lowercase_							,  lowercase_=14							,  lowercase_=7							,  lowercase_=True							,  lowercase_=True							,  lowercase_=False							,  lowercase_=True							,  lowercase_=99							,  lowercase_=32							,  lowercase_=5							,  lowercase_=4							,  lowercase_=37							,  lowercase_="gelu"							,  lowercase_=0.1							,  lowercase_=0.1							,  lowercase_=512							,  lowercase_=0.02							,  ):

     """simple docstring"""
     UpperCAmelCase_   :   Tuple     	=       parent
     UpperCAmelCase_   :   str     	=       batch_size
     UpperCAmelCase_   :   Dict     	=       seq_length
     UpperCAmelCase_   :   Optional[Any]     	=       is_training
     UpperCAmelCase_   :   str     	=       use_input_mask
     UpperCAmelCase_   :   Optional[Any]     	=       use_token_type_ids
     UpperCAmelCase_   :   Dict     	=       use_labels
     UpperCAmelCase_   :   Tuple     	=       vocab_size
     UpperCAmelCase_   :   str     	=       hidden_size
     UpperCAmelCase_   :   List[Any]     	=       num_hidden_layers
     UpperCAmelCase_   :   List[str]     	=       num_attention_heads
     UpperCAmelCase_   :   Optional[int]     	=       intermediate_size
     UpperCAmelCase_   :   Tuple     	=       hidden_act
     UpperCAmelCase_   :   List[Any]     	=       hidden_dropout_prob
     UpperCAmelCase_   :   Dict     	=       attention_probs_dropout_prob
     UpperCAmelCase_   :   List[Any]     	=       max_position_embeddings
     UpperCAmelCase_   :   str     	=       initializer_range
     UpperCAmelCase_   :   List[str]     	=       None
     UpperCAmelCase_   :   Any     	=       vocab_size - 1
     UpperCAmelCase_   :   Any     	=       vocab_size - 1
     UpperCAmelCase_   :   Union[str, Any]     	=       vocab_size - 1







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   int     	=       ids_tensor([self.batch_size, self.seq_length]							,  self.vocab_size    )

     UpperCAmelCase_   :   Union[str, Any]     	=       None
     if self.use_input_mask:
        UpperCAmelCase_   :   Tuple     	=       random_attention_mask([self.batch_size, self.seq_length]    )

     UpperCAmelCase_   :   Tuple     	=       GPTaConfig(
         vocab_size=self.vocab_size							,  n_embd=self.hidden_size							,  n_layer=self.num_hidden_layers							,  n_head=self.num_attention_heads							,  n_positions=self.max_position_embeddings							,  use_cache=_lowercase							,  bos_token_id=self.bos_token_id							,  eos_token_id=self.eos_token_id							,  pad_token_id=self.pad_token_id							,  )

     return (config, input_ids, input_mask)







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Union[str, Any]     	=       self.prepare_config_and_inputs()
     UpperCAmelCase_   :   Dict     	=       config_and_inputs
     UpperCAmelCase_   :   Optional[Any]     	=       {'input_ids': input_ids, 'attention_mask': attention_mask}
     return config, inputs_dict







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Union[str, Any]     	=       self.prepare_config_and_inputs()

     UpperCAmelCase_   :   Optional[int]     	=       floats_tensor([self.batch_size, self.seq_length, self.hidden_size]    )
     UpperCAmelCase_   :   str     	=       ids_tensor([self.batch_size, self.seq_length]							,  vocab_size=2    )

     return (
         config,
         input_ids,
         attention_mask,
         encoder_hidden_states,
         encoder_attention_mask,
     )







  def 			UpperCamelCase__   (						self							,  lowercase_							,  lowercase_							,  lowercase_							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   List[Any]     	=       20
     UpperCAmelCase_   :   str     	=       model_class_name(_lowercase    )

     UpperCAmelCase_   :   Union[str, Any]     	=       model.init_cache(input_ids.shape[0]							,  _lowercase    )
     UpperCAmelCase_   :   Optional[Any]     	=       jnp.ones((input_ids.shape[0], max_decoder_length)							,  dtype="i4"    )

     UpperCAmelCase_   :   Tuple     	=       jnp.broadcast_to(
         jnp.arange(input_ids.shape[-1] - 1    )[None, :]							,  (input_ids.shape[0], input_ids.shape[-1] - 1)    )
     UpperCAmelCase_   :   List[Any]     	=       model(
         input_ids[:, :-1]							,  attention_mask=_lowercase							,  past_key_values=_lowercase							,  position_ids=_lowercase							,  )

     UpperCAmelCase_   :   Optional[int]     	=       jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]							,  dtype="i4"    )
     UpperCAmelCase_   :   Union[str, Any]     	=       model(
         input_ids[:, -1:]							,  attention_mask=_lowercase							,  past_key_values=outputs_cache.past_key_values							,  position_ids=_lowercase							,  )

     UpperCAmelCase_   :   str     	=       model(_lowercase    )

     UpperCAmelCase_   :   Dict     	=       np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])    )    )
     self.parent.assertTrue(diff < 1E-3							,  msg=F"""Max diff is {diff}"""    )







  def 			UpperCamelCase__   (						self							,  lowercase_							,  lowercase_							,  lowercase_							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   str     	=       20
     UpperCAmelCase_   :   int     	=       model_class_name(_lowercase    )

     UpperCAmelCase_   :   Union[str, Any]     	=       jnp.concatenate(
         [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])    )]							,  axis=-1							,  )

     UpperCAmelCase_   :   List[Any]     	=       model.init_cache(input_ids.shape[0]							,  _lowercase    )
     UpperCAmelCase_   :   List[Any]     	=       jnp.broadcast_to(
         jnp.arange(input_ids.shape[-1] - 1    )[None, :]							,  (input_ids.shape[0], input_ids.shape[-1] - 1)    )

     UpperCAmelCase_   :   Optional[int]     	=       model(
         input_ids[:, :-1]							,  attention_mask=_lowercase							,  past_key_values=_lowercase							,  position_ids=_lowercase							,  )
     UpperCAmelCase_   :   Any     	=       jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]							,  dtype="i4"    )
     UpperCAmelCase_   :   str     	=       model(
         input_ids[:, -1:]							,  past_key_values=outputs_cache.past_key_values							,  attention_mask=_lowercase							,  position_ids=_lowercase							,  )

     UpperCAmelCase_   :   Any     	=       model(_lowercase							,  attention_mask=_lowercase    )

     UpperCAmelCase_   :   Tuple     	=       np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])    )    )
     self.parent.assertTrue(diff < 1E-3							,  msg=F"""Max diff is {diff}"""    )




@require_flax
class A_      (UpperCAmelCase_							,UpperCAmelCase_							,unittest.TestCase ):




  '''simple docstring'''
  SCREAMING_SNAKE_CASE__     :		Optional[int]    	=						(FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
  SCREAMING_SNAKE_CASE__     :		str    	=						(FlaxGPTaLMHeadModel,) if is_flax_available() else ()







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Optional[Any]     	=       FlaxGPTaModelTester(self    )







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     for model_class_name in self.all_model_classes:
        UpperCAmelCase_   :   List[Any]     	=       self.model_tester.prepare_config_and_inputs()
        self.model_tester.check_use_cache_forward(_lowercase							,  _lowercase							,  _lowercase							,  _lowercase    )







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     for model_class_name in self.all_model_classes:
        UpperCAmelCase_   :   Optional[Any]     	=       self.model_tester.prepare_config_and_inputs()
        self.model_tester.check_use_cache_forward_with_attn_mask(
            _lowercase							,  _lowercase							,  _lowercase							,  _lowercase    )







  @slow
  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Dict     	=       GPTaTokenizer.from_pretrained("gpt2"							,  pad_token="</s>"							,  padding_side="left"    )
     UpperCAmelCase_   :   str     	=       tokenizer(["Hello this is a long string", "Hey"]							,  return_tensors="np"							,  padding=_lowercase							,  truncation=_lowercase    )

     UpperCAmelCase_   :   Any     	=       FlaxGPTaLMHeadModel.from_pretrained("gpt2"    )
     UpperCAmelCase_   :   Any     	=       False
     UpperCAmelCase_   :   int     	=       model.config.eos_token_id

     UpperCAmelCase_   :   Any     	=       jax.jit(model.generate    )

     UpperCAmelCase_   :   List[str]     	=       jit_generate(inputs["input_ids"]							,  attention_mask=inputs["attention_mask"]    ).sequences

     UpperCAmelCase_   :   Any     	=       tokenizer.batch_decode(_lowercase							,  skip_special_tokens=_lowercase    )

     UpperCAmelCase_   :   Optional[int]     	=       [
         'Hello this is a long string of words. I\'m going to start with the first one.\n',
         'Hey, I\'m not sure if I\'m going to be able to do',
     ]

     self.assertListEqual(_lowercase							,  _lowercase    )







  @is_pt_flax_cross_test
  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Optional[Any]     	=       self.model_tester.prepare_config_and_inputs_for_common()

     for model_class in self.all_model_classes:
        with self.subTest(model_class.__name__    ):
           # prepare inputs
           UpperCAmelCase_   :   Union[str, Any]     	=       self._prepare_for_class(_lowercase							,  _lowercase    )
           UpperCAmelCase_   :   List[Any]     	=       {k: torch.tensor(v.tolist()    ) for k, v in prepared_inputs_dict.items()}

           # load corresponding PyTorch class
           UpperCAmelCase_   :   str     	=       model_class.__name__[4:]  # Skip the "Flax" at the beginning
           UpperCAmelCase_   :   List[Any]     	=       getattr(_lowercase							,  _lowercase    )

           UpperCAmelCase_   :   List[str]     	=       pt_inputs['input_ids'].shape
           UpperCAmelCase_   :   Optional[Any]     	=       np.random.randint(0							,  seq_length - 1							,  size=(batch_size,)    )
           for batch_idx, start_index in enumerate(_lowercase    ):
              UpperCAmelCase_   :   List[str]     	=       0
              UpperCAmelCase_   :   List[str]     	=       1
              UpperCAmelCase_   :   List[Any]     	=       0
              UpperCAmelCase_   :   Optional[int]     	=       1
           UpperCAmelCase_   :   Dict     	=       pt_model_class(_lowercase    ).eval()
           UpperCAmelCase_   :   List[str]     	=       model_class(_lowercase							,  dtype=jnp.floataa    )

           UpperCAmelCase_   :   List[Any]     	=       convert_pytorch_state_dict_to_flax(pt_model.state_dict()							,  _lowercase    )
           UpperCAmelCase_   :   Optional[Any]     	=       fx_state

           with torch.no_grad():
              UpperCAmelCase_   :   Optional[Any]     	=       pt_model(**_lowercase    ).to_tuple()

           UpperCAmelCase_   :   List[str]     	=       fx_model(**_lowercase    ).to_tuple()
           self.assertEqual(len(_lowercase    )							,  len(_lowercase    )							,  "Output lengths differ between Flax and PyTorch"    )
           for fx_output, pt_output in zip(_lowercase							,  _lowercase    ):
              self.assert_almost_equals(fx_output[:, -1]							,  pt_output[:, -1].numpy()							,  4E-2    )

           with tempfile.TemporaryDirectory() as tmpdirname:
              pt_model.save_pretrained(_lowercase    )
              UpperCAmelCase_   :   Union[str, Any]     	=       model_class.from_pretrained(_lowercase							,  from_pt=_lowercase    )

           UpperCAmelCase_   :   int     	=       fx_model_loaded(**_lowercase    ).to_tuple()
           self.assertEqual(
               len(_lowercase    )							,  len(_lowercase    )							,  "Output lengths differ between Flax and PyTorch"    )
           for fx_output_loaded, pt_output in zip(_lowercase							,  _lowercase    ):
              self.assert_almost_equals(fx_output_loaded[:, -1]							,  pt_output[:, -1].numpy()							,  4E-2    )







  @is_pt_flax_cross_test
  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Any     	=       self.model_tester.prepare_config_and_inputs_for_common()
     for model_class in self.all_model_classes:
        with self.subTest(model_class.__name__    ):
           # prepare inputs
           UpperCAmelCase_   :   Any     	=       self._prepare_for_class(_lowercase							,  _lowercase    )
           UpperCAmelCase_   :   Any     	=       {k: torch.tensor(v.tolist()    ) for k, v in prepared_inputs_dict.items()}

           # load corresponding PyTorch class
           UpperCAmelCase_   :   Dict     	=       model_class.__name__[4:]  # Skip the "Flax" at the beginning
           UpperCAmelCase_   :   Optional[Any]     	=       getattr(_lowercase							,  _lowercase    )

           UpperCAmelCase_   :   Union[str, Any]     	=       pt_model_class(_lowercase    ).eval()
           UpperCAmelCase_   :   List[Any]     	=       model_class(_lowercase							,  dtype=jnp.floataa    )

           UpperCAmelCase_   :   int     	=       load_flax_weights_in_pytorch_model(_lowercase							,  fx_model.params    )
           UpperCAmelCase_   :   int     	=       pt_inputs['input_ids'].shape
           UpperCAmelCase_   :   List[str]     	=       np.random.randint(0							,  seq_length - 1							,  size=(batch_size,)    )
           for batch_idx, start_index in enumerate(_lowercase    ):
              UpperCAmelCase_   :   Tuple     	=       0
              UpperCAmelCase_   :   Optional[int]     	=       1
              UpperCAmelCase_   :   Optional[int]     	=       0
              UpperCAmelCase_   :   List[str]     	=       1

           # make sure weights are tied in PyTorch
           pt_model.tie_weights()

           with torch.no_grad():
              UpperCAmelCase_   :   Tuple     	=       pt_model(**_lowercase    ).to_tuple()

           UpperCAmelCase_   :   Tuple     	=       fx_model(**_lowercase    ).to_tuple()
           self.assertEqual(len(_lowercase    )							,  len(_lowercase    )							,  "Output lengths differ between Flax and PyTorch"    )
           for fx_output, pt_output in zip(_lowercase							,  _lowercase    ):
              self.assert_almost_equals(fx_output[:, -1]							,  pt_output[:, -1].numpy()							,  4E-2    )

           with tempfile.TemporaryDirectory() as tmpdirname:
              fx_model.save_pretrained(_lowercase    )
              UpperCAmelCase_   :   int     	=       pt_model_class.from_pretrained(_lowercase							,  from_flax=_lowercase    )

           with torch.no_grad():
              UpperCAmelCase_   :   List[str]     	=       pt_model_loaded(**_lowercase    ).to_tuple()

           self.assertEqual(
               len(_lowercase    )							,  len(_lowercase    )							,  "Output lengths differ between Flax and PyTorch"    )
           for fx_output, pt_output in zip(_lowercase							,  _lowercase    ):
              self.assert_almost_equals(fx_output[:, -1]							,  pt_output[:, -1].numpy()							,  4E-2    )







  @slow
  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     for model_class_name in self.all_model_classes:
        UpperCAmelCase_   :   List[Any]     	=       model_class_name.from_pretrained("gpt2"							,  from_pt=_lowercase    )
        UpperCAmelCase_   :   Any     	=       model(np.ones((1, 1)    )    )
        self.assertIsNotNone(_lowercase    )










'''simple docstring'''

import importlib
import os
import platform
from pathlib import Path

from packaging import version

from .utils.logging import get_logger


A:   str						=					get_logger(__name__)

# Datasets
A:   Optional[Any]						=					"https://s3.amazonaws.com/datasets.huggingface.co/datasets/datasets"
A:   Any						=					"https://cdn-datasets.huggingface.co/datasets/datasets"
A:   Dict						=					"https://raw.githubusercontent.com/huggingface/datasets/{revision}/datasets/{path}/{name}"

# Metrics
A:   List[str]						=					"https://s3.amazonaws.com/datasets.huggingface.co/datasets/metrics"
A:   Any						=					"https://cdn-datasets.huggingface.co/datasets/metric"
A:   List[str]						=					"https://raw.githubusercontent.com/huggingface/datasets/{revision}/metrics/{path}/{name}"

# Hub
A:   str						=					os.environ.get("HF_ENDPOINT", "https://huggingface.co")
A:   List[Any]						=					HF_ENDPOINT + "/datasets/{repo_id}/resolve/{revision}/{path}"
A:   List[Any]						=					"main"

A:   Any						=					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
A:   Optional[Any]						=					{"1", "ON", "YES", "TRUE"}
A:   Optional[int]						=					ENV_VARS_TRUE_VALUES.union({"AUTO"})


# Imports
A:   Any						=					version.parse(importlib_metadata.version("dill"))
A:   str						=					version.parse(importlib_metadata.version("pandas"))
A:   Tuple						=					version.parse(importlib_metadata.version("pyarrow"))

A:   str						=					os.environ.get("USE_TF", "AUTO").upper()
A:   List[Any]						=					os.environ.get("USE_TORCH", "AUTO").upper()
A:   Union[str, Any]						=					os.environ.get("USE_JAX", "AUTO").upper()

A:   Dict						=					"N/A"
A:   Optional[int]						=					False

if USE_TORCH in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TF not in ENV_VARS_TRUE_VALUES:
						A:   List[str]						=					importlib.util.find_spec("torch") is not None
						if TORCH_AVAILABLE:
												try:
																		A:   List[str]						=					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")

A:   Union[str, Any]						=					"N/A"
A:   Dict						=					False

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


A:   Any						=					"N/A"
A:   int						=					False

if USE_JAX in ENV_VARS_TRUE_AND_AUTO_VALUES:
						A:   Dict						=					importlib.util.find_spec("jax") is not None and importlib.util.find_spec("jaxlib") is not None
						if JAX_AVAILABLE:
												try:
																		A:   List[str]						=					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")


A:   Optional[Any]						=					os.environ.get("USE_BEAM", "AUTO").upper()
A:   Any						=					"N/A"
A:   List[Any]						=					False
if USE_BEAM in ENV_VARS_TRUE_AND_AUTO_VALUES:
						try:
												A:   Tuple						=					version.parse(importlib_metadata.version("apache_beam"))
												A:   Dict						=					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
A:   Union[str, Any]						=					importlib.util.find_spec("sqlalchemy") is not None

# Optional tools for feature decoding
A:   Optional[int]						=					importlib.util.find_spec("PIL") is not None
A:   Dict						=					importlib.util.find_spec("soundfile") is not None and version.parse(
    importlib.import_module("soundfile").__libsndfile_version__
) >= version.parse("1.0.31")
A:   Any						=					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
A:   Optional[Any]						=					importlib.util.find_spec("rarfile") is not None
A:   Any						=					importlib.util.find_spec("zstandard") is not None
A:   Union[str, Any]						=					importlib.util.find_spec("lz4") is not None
A:   str						=					importlib.util.find_spec("py7zr") is not None


# Cache location
A:   Any						=					"~/.cache"
A:   Tuple						=					os.getenv("XDG_CACHE_HOME", DEFAULT_XDG_CACHE_HOME)
A:   Dict						=					os.path.join(XDG_CACHE_HOME, "huggingface")
A:   List[str]						=					os.path.expanduser(os.getenv("HF_HOME", DEFAULT_HF_CACHE_HOME))

A:   int						=					os.path.join(HF_CACHE_HOME, "datasets")
A:   int						=					Path(os.getenv("HF_DATASETS_CACHE", DEFAULT_HF_DATASETS_CACHE))

A:   int						=					os.path.join(HF_CACHE_HOME, "metrics")
A:   int						=					Path(os.getenv("HF_METRICS_CACHE", DEFAULT_HF_METRICS_CACHE))

A:   Any						=					os.path.join(HF_CACHE_HOME, "modules")
A:   Tuple						=					Path(os.getenv("HF_MODULES_CACHE", DEFAULT_HF_MODULES_CACHE))

A:   List[str]						=					"downloads"
A:   Tuple						=					os.path.join(HF_DATASETS_CACHE, DOWNLOADED_DATASETS_DIR)
A:   Union[str, Any]						=					Path(os.getenv("HF_DATASETS_DOWNLOADED_DATASETS_PATH", DEFAULT_DOWNLOADED_DATASETS_PATH))

A:   Tuple						=					"extracted"
A:   Optional[int]						=					os.path.join(DEFAULT_DOWNLOADED_DATASETS_PATH, EXTRACTED_DATASETS_DIR)
A:   Optional[int]						=					Path(os.getenv("HF_DATASETS_EXTRACTED_DATASETS_PATH", DEFAULT_EXTRACTED_DATASETS_PATH))

# Download count for the website
A:   Union[str, Any]						=					(
    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)
A:   List[str]						=					1_0_0_0

# Size of the preloaded record batch in `Dataset.__iter__`
A:   Tuple						=					1_0

# Pickling tables works only for small tables (<4GiB)
# For big tables, we write them on disk instead
A:   List[Any]						=					4 << 3_0

# Max shard size in bytes (e.g. to shard parquet datasets in push_to_hub or download_and_prepare)
A:   List[str]						=					"500MB"

# Parquet configuration
A:   Union[str, Any]						=					1_0_0
A:   Optional[int]						=					1_0_0
A:   Any						=					1_0_0

# Offline mode
A:   List[str]						=					os.environ.get("HF_DATASETS_OFFLINE", "AUTO").upper() in ENV_VARS_TRUE_VALUES

# In-memory
A:   Any						=					0  # Disabled
A:   List[str]						=					float(os.environ.get("HF_DATASETS_IN_MEMORY_MAX_SIZE", DEFAULT_IN_MEMORY_MAX_SIZE))

# File names
A:   List[str]						=					"dataset.arrow"
A:   Optional[int]						=					"indices.arrow"
A:   List[str]						=					"state.json"
A:   Tuple						=					"dataset_info.json"
A:   Tuple						=					"dataset_infos.json"
A:   Dict						=					"LICENSE"
A:   Optional[Any]						=					"metric_info.json"
A:   Any						=					"dataset_dict.json"

A:   Dict						=					"datasets_modules"

A:   List[str]						=					2_5_5

# Streaming
A:   Any						=					2_0
A:   Dict						=					5

# Datasets without script
A:   Union[str, Any]						=					2_0_0
A:   Union[str, Any]						=					1_0
A:   List[Any]						=					2_0_0

# Progress bars
A:   Tuple						=					0.05  # 20 progress updates per sec
