import unittest

import numpy as np

from transformers import is_flax_available
from transformers.testing_utils import require_flax

from ..test_modeling_flax_common import ids_tensor


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

							from transformers.generation import (
							    FlaxForcedBOSTokenLogitsProcessor,
							    FlaxForcedEOSTokenLogitsProcessor,
							    FlaxLogitsProcessorList,
							    FlaxMinLengthLogitsProcessor,
							    FlaxTemperatureLogitsWarper,
							    FlaxTopKLogitsWarper,
							    FlaxTopPLogitsWarper,
							)


@require_flax
class 						SCREAMING_SNAKE_CASE__    (     unittest.TestCase     ):




							def 	__snake_case(						self   :					List[Any]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int      )					->				Tuple:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       jnp.ones((batch_size, length)      ) / length
												return scores




							def 	__snake_case(						self   :					int      )					->				Union[str, Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       None
												SCREAMING_SNAKE_CASE    			=       20

												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(batch_size=2	,							length=__A      )

												# tweak scores to not be uniform anymore
												SCREAMING_SNAKE_CASE    			=       scores.at[1, 5].set((1 / length) + 0.1      )  # peak, 1st batch
												SCREAMING_SNAKE_CASE    			=       scores.at[1, 10].set((1 / length) - 0.4      )  # valley, 1st batch

												# compute softmax
												SCREAMING_SNAKE_CASE    			=       jax.nn.softmax(__A	,							axis=-1      )

												SCREAMING_SNAKE_CASE    			=       FlaxTemperatureLogitsWarper(temperature=0.5      )
												SCREAMING_SNAKE_CASE    			=       FlaxTemperatureLogitsWarper(temperature=1.3      )

												SCREAMING_SNAKE_CASE    			=       jax.nn.softmax(temp_dist_warper_sharper(__A	,							scores.copy()	,							cur_len=__A      )	,							axis=-1      )
												SCREAMING_SNAKE_CASE    			=       jax.nn.softmax(temp_dist_warper_smoother(__A	,							scores.copy()	,							cur_len=__A      )	,							axis=-1      )

												# uniform distribution stays uniform
												self.assertTrue(jnp.allclose(probs[0, :]	,							warped_prob_sharp[0, :]	,							atol=1e-3      )      )
												self.assertTrue(jnp.allclose(probs[0, :]	,							warped_prob_smooth[0, :]	,							atol=1e-3      )      )

												# sharp peaks get higher, valleys get lower
												self.assertLess(probs[1, :].max()	,							warped_prob_sharp[1, :].max()      )
												self.assertGreater(probs[1, :].min()	,							warped_prob_sharp[1, :].min()      )

												# smooth peaks get lower, valleys get higher
												self.assertGreater(probs[1, :].max()	,							warped_prob_smooth[1, :].max()      )
												self.assertLess(probs[1, :].min()	,							warped_prob_smooth[1, :].min()      )




							def 	__snake_case(						self   :					List[Any]      )					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       None
												SCREAMING_SNAKE_CASE    			=       10
												SCREAMING_SNAKE_CASE    			=       2

												# create ramp distribution
												SCREAMING_SNAKE_CASE    			=       np.broadcast_to(np.arange(__A      )[None, :]	,							(batch_size, vocab_size)      ).copy()
												SCREAMING_SNAKE_CASE    			=       ramp_logits[1:, : vocab_size // 2] + vocab_size

												SCREAMING_SNAKE_CASE    			=       FlaxTopKLogitsWarper(3      )

												SCREAMING_SNAKE_CASE    			=       top_k_warp(__A	,							__A	,							cur_len=__A      )

												# check that correct tokens are filtered
												self.assertListEqual(jnp.isinf(scores[0]      ).tolist()	,							7 * [True] + 3 * [False]      )
												self.assertListEqual(jnp.isinf(scores[1]      ).tolist()	,							2 * [True] + 3 * [False] + 5 * [True]      )

												# check special case
												SCREAMING_SNAKE_CASE    			=       5
												SCREAMING_SNAKE_CASE    			=       FlaxTopKLogitsWarper(top_k=1	,							filter_value=0.0	,							min_tokens_to_keep=3      )

												SCREAMING_SNAKE_CASE    			=       np.broadcast_to(np.arange(__A      )[None, :]	,							(batch_size, length)      ).copy()
												SCREAMING_SNAKE_CASE    			=       top_k_warp_safety_check(__A	,							__A	,							cur_len=__A      )

												# min_tokens overwrites k: 3 tokens are kept => 2 tokens are nullified
												self.assertListEqual((scores == 0.0).sum(axis=-1      ).tolist()	,							[2, 2]      )




							def 	__snake_case(						self   :					Tuple      )					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       None
												SCREAMING_SNAKE_CASE    			=       10
												SCREAMING_SNAKE_CASE    			=       2

												# create distribution and take log (inverse to Softmax as taken in TopPLogitsWarper)
												SCREAMING_SNAKE_CASE    			=       np.log(np.array([[0.3, 0.1, 0.1, 0.5], [0.1_5, 0.3, 0.3, 0.2_5]]      )      )

												SCREAMING_SNAKE_CASE    			=       FlaxTopPLogitsWarper(0.8      )
												SCREAMING_SNAKE_CASE    			=       np.exp(top_p_warp(__A	,							__A	,							cur_len=__A      )      )

												# dist should be filtered to keep min num values so that sum is >= top_p
												# exp (-inf) => 0
												SCREAMING_SNAKE_CASE    			=       np.array([[0.3, 0.0, 0.0, 0.5], [0.0, 0.3, 0.3, 0.2_5]]      )
												self.assertTrue(np.allclose(__A	,							__A	,							atol=1e-3      )      )

												# check edge cases with negative and extreme logits
												SCREAMING_SNAKE_CASE    			=       np.broadcast_to(np.arange(__A      )[None, :]	,							(batch_size, vocab_size)      ).copy() - (
												    vocab_size // 2
												)

												# make ramp_logits more extreme
												SCREAMING_SNAKE_CASE    			=       ramp_logits[1] * 1_0_0.0

												# make sure at least 2 tokens are kept
												SCREAMING_SNAKE_CASE    			=       FlaxTopPLogitsWarper(0.9	,							min_tokens_to_keep=2	,							filter_value=0.0      )
												SCREAMING_SNAKE_CASE    			=       top_p_warp(__A	,							__A	,							cur_len=__A      )

												# first batch should keep three tokens, second batch would keep only 1, but due to `min_tokens_to_keep=2` keeps 2.
												self.assertListEqual((filtered_dist != 0.0).sum(axis=-1      ).tolist()	,							[3, 2]      )




							def 	__snake_case(						self   :					Any      )					->				Union[str, Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       20
												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       0

												SCREAMING_SNAKE_CASE    			=       FlaxMinLengthLogitsProcessor(min_length=10	,							eos_token_id=__A      )

												# check that min length is applied at length 5
												SCREAMING_SNAKE_CASE    			=       ids_tensor((batch_size, 20)	,							vocab_size=20      )
												SCREAMING_SNAKE_CASE    			=       5
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       min_dist_processor(__A	,							__A	,							cur_len=__A      )
												self.assertListEqual(scores_before_min_length[:, eos_token_id].tolist()	,							4 * [-float("inf"      )]      )

												# check that min length is not applied anymore at length 15
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       15
												SCREAMING_SNAKE_CASE    			=       min_dist_processor(__A	,							__A	,							cur_len=__A      )
												self.assertFalse(jnp.isinf(__A      ).any()      )




							def 	__snake_case(						self   :					Union[str, Any]      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       20
												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       0

												SCREAMING_SNAKE_CASE    			=       FlaxForcedBOSTokenLogitsProcessor(bos_token_id=__A      )

												# check that all scores are -inf except the bos_token_id score
												SCREAMING_SNAKE_CASE    			=       ids_tensor((batch_size, 1)	,							vocab_size=20      )
												SCREAMING_SNAKE_CASE    			=       1
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       logits_processor(__A	,							__A	,							cur_len=__A      )
												self.assertTrue(jnp.isneginf(scores[:, bos_token_id + 1 :]      ).all()      )
												self.assertListEqual(scores[:, bos_token_id].tolist()	,							4 * [0]      )  # score for bos_token_id shold be zero

												# check that bos_token_id is not forced if current length is greater than 1
												SCREAMING_SNAKE_CASE    			=       3
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       logits_processor(__A	,							__A	,							cur_len=__A      )
												self.assertFalse(jnp.isinf(__A      ).any()      )




							def 	__snake_case(						self   :					Any      )					->				int:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       20
												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       0
												SCREAMING_SNAKE_CASE    			=       5

												SCREAMING_SNAKE_CASE    			=       FlaxForcedEOSTokenLogitsProcessor(max_length=__A	,							eos_token_id=__A      )

												# check that all scores are -inf except the eos_token_id when max_length is reached
												SCREAMING_SNAKE_CASE    			=       ids_tensor((batch_size, 4)	,							vocab_size=20      )
												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       logits_processor(__A	,							__A	,							cur_len=__A      )
												self.assertTrue(jnp.isneginf(scores[:, eos_token_id + 1 :]      ).all()      )
												self.assertListEqual(scores[:, eos_token_id].tolist()	,							4 * [0]      )  # score for eos_token_id should be zero

												# check that eos_token_id is not forced if max_length is not reached
												SCREAMING_SNAKE_CASE    			=       3
												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       logits_processor(__A	,							__A	,							cur_len=__A      )
												self.assertFalse(jnp.isinf(__A      ).any()      )




							def 	__snake_case(						self   :					int      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       10
												SCREAMING_SNAKE_CASE    			=       15
												SCREAMING_SNAKE_CASE    			=       2
												SCREAMING_SNAKE_CASE    			=       1
												SCREAMING_SNAKE_CASE    			=       15

												# dummy input_ids and scores
												SCREAMING_SNAKE_CASE    			=       ids_tensor((batch_size, sequence_length)	,							__A      )
												SCREAMING_SNAKE_CASE    			=       input_ids.copy()

												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       scores.copy()

												# instantiate all dist processors
												SCREAMING_SNAKE_CASE    			=       FlaxTemperatureLogitsWarper(temperature=0.5      )
												SCREAMING_SNAKE_CASE    			=       FlaxTopKLogitsWarper(3      )
												SCREAMING_SNAKE_CASE    			=       FlaxTopPLogitsWarper(0.8      )

												# instantiate all logits processors
												SCREAMING_SNAKE_CASE    			=       FlaxMinLengthLogitsProcessor(min_length=10	,							eos_token_id=__A      )
												SCREAMING_SNAKE_CASE    			=       FlaxForcedBOSTokenLogitsProcessor(bos_token_id=__A      )
												SCREAMING_SNAKE_CASE    			=       FlaxForcedEOSTokenLogitsProcessor(max_length=__A	,							eos_token_id=__A      )

												SCREAMING_SNAKE_CASE    			=       10

												# no processor list
												SCREAMING_SNAKE_CASE    			=       temp_dist_warp(__A	,							__A	,							cur_len=__A      )
												SCREAMING_SNAKE_CASE    			=       top_k_warp(__A	,							__A	,							cur_len=__A      )
												SCREAMING_SNAKE_CASE    			=       top_p_warp(__A	,							__A	,							cur_len=__A      )
												SCREAMING_SNAKE_CASE    			=       min_dist_proc(__A	,							__A	,							cur_len=__A      )
												SCREAMING_SNAKE_CASE    			=       bos_dist_proc(__A	,							__A	,							cur_len=__A      )
												SCREAMING_SNAKE_CASE    			=       eos_dist_proc(__A	,							__A	,							cur_len=__A      )

												# with processor list
												SCREAMING_SNAKE_CASE    			=       FlaxLogitsProcessorList(
												    [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc]      )
												SCREAMING_SNAKE_CASE    			=       processor(__A	,							__A	,							cur_len=__A      )

												# scores should be equal
												self.assertTrue(jnp.allclose(__A	,							__A	,							atol=1e-3      )      )

												# input_ids should never be changed
												self.assertListEqual(input_ids.tolist()	,							input_ids_comp.tolist()      )





							def 	__snake_case(						self   :					Optional[int]      )					->				int:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       4
												SCREAMING_SNAKE_CASE    			=       10
												SCREAMING_SNAKE_CASE    			=       15
												SCREAMING_SNAKE_CASE    			=       2
												SCREAMING_SNAKE_CASE    			=       1
												SCREAMING_SNAKE_CASE    			=       15

												# dummy input_ids and scores
												SCREAMING_SNAKE_CASE    			=       ids_tensor((batch_size, sequence_length)	,							__A      )
												SCREAMING_SNAKE_CASE    			=       input_ids.copy()

												SCREAMING_SNAKE_CASE    			=       self._get_uniform_logits(__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       scores.copy()

												# instantiate all dist processors
												SCREAMING_SNAKE_CASE    			=       FlaxTemperatureLogitsWarper(temperature=0.5      )
												SCREAMING_SNAKE_CASE    			=       FlaxTopKLogitsWarper(3      )
												SCREAMING_SNAKE_CASE    			=       FlaxTopPLogitsWarper(0.8      )

												# instantiate all logits processors
												SCREAMING_SNAKE_CASE    			=       FlaxMinLengthLogitsProcessor(min_length=10	,							eos_token_id=__A      )
												SCREAMING_SNAKE_CASE    			=       FlaxForcedBOSTokenLogitsProcessor(bos_token_id=__A      )
												SCREAMING_SNAKE_CASE    			=       FlaxForcedEOSTokenLogitsProcessor(max_length=__A	,							eos_token_id=__A      )

												SCREAMING_SNAKE_CASE    			=       10

												# no processor list
												def run_no_processor_list(_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					List[Any]      ):
																	SCREAMING_SNAKE_CASE    			=       temp_dist_warp(__A	,							__A	,							cur_len=__A      )
																	SCREAMING_SNAKE_CASE    			=       top_k_warp(__A	,							__A	,							cur_len=__A      )
																	SCREAMING_SNAKE_CASE    			=       top_p_warp(__A	,							__A	,							cur_len=__A      )
																	SCREAMING_SNAKE_CASE    			=       min_dist_proc(__A	,							__A	,							cur_len=__A      )
																	SCREAMING_SNAKE_CASE    			=       bos_dist_proc(__A	,							__A	,							cur_len=__A      )
																	SCREAMING_SNAKE_CASE    			=       eos_dist_proc(__A	,							__A	,							cur_len=__A      )
																	return scores

												# with processor list
												def run_processor_list(_UpperCamelCase   :					str	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int      ):
																	SCREAMING_SNAKE_CASE    			=       FlaxLogitsProcessorList(
																	    [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc]      )
																	SCREAMING_SNAKE_CASE    			=       processor(__A	,							__A	,							cur_len=__A      )
																	return scores

												SCREAMING_SNAKE_CASE    			=       jax.jit(__A      )
												SCREAMING_SNAKE_CASE    			=       jax.jit(__A      )

												SCREAMING_SNAKE_CASE    			=       jitted_run_no_processor_list(__A	,							__A	,							__A      )
												SCREAMING_SNAKE_CASE    			=       jitted_run_processor_list(__A	,							__A	,							__A      )

												# scores should be equal
												self.assertTrue(jnp.allclose(__A	,							__A	,							atol=1e-3      )      )

												# input_ids should never be changed
												self.assertListEqual(input_ids.tolist()	,							input_ids_comp.tolist()      )





import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


_lowerCamelCase					:   str							=		threading.Lock()
_lowerCamelCase					:   Optional[logging.Handler]							=		None

_lowerCamelCase					:   Any							=		{
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

_lowerCamelCase					:   Union[str, Any]							=		logging.WARNING

_lowerCamelCase					:   List[Any]							=		True





def 	__lowerCamelCase							():
					SCREAMING_SNAKE_CASE    			=       os.getenv("TRANSFORMERS_VERBOSITY"      , UpperCAmelCase__  )
					if env_level_str:
										if env_level_str in log_levels:
															return log_levels[env_level_str]
										else:
															logging.getLogger().warning(
															    F"Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, "
															    F"has to be one of: { ', '.join(log_levels.keys()  ) }"  )
					return _default_log_level





def 	__lowerCamelCase							():
					return __name__.split("."  )[0]





def 	__lowerCamelCase							():
					return logging.getLogger(_get_library_name()  )





def 	__lowerCamelCase							():
					global _default_handler

					with _lock:
										if _default_handler:
															# This library has already configured the library root logger.
															return
										SCREAMING_SNAKE_CASE    			=       logging.StreamHandler()  # Set sys.stderr as stream.
										SCREAMING_SNAKE_CASE    			=       sys.stderr.flush

										# Apply our default configuration to the library root logger.
										SCREAMING_SNAKE_CASE    			=       _get_library_root_logger()
										library_root_logger.addHandler(_default_handler  )
										library_root_logger.setLevel(_get_default_logging_level()  )
										SCREAMING_SNAKE_CASE    			=       False





def 	__lowerCamelCase							():
					global _default_handler

					with _lock:
										if not _default_handler:
															return

										SCREAMING_SNAKE_CASE    			=       _get_library_root_logger()
										library_root_logger.removeHandler(_default_handler  )
										library_root_logger.setLevel(logging.NOTSET  )
										SCREAMING_SNAKE_CASE    			=       None





def 	__lowerCamelCase							():
					return log_levels





def 	__lowerCamelCase							(UpperCAmelCase__     :							Optional[str] = None  ):

					if name is None:
										SCREAMING_SNAKE_CASE    			=       _get_library_name()

					_configure_library_root_logger()
					return logging.getLogger(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					_configure_library_root_logger()
					return _get_library_root_logger().getEffectiveLevel()





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):
					_configure_library_root_logger()
					_get_library_root_logger().setLevel(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					return set_verbosity(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					return set_verbosity(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					return set_verbosity(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					return set_verbosity(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					_configure_library_root_logger()

					assert _default_handler is not None
					_get_library_root_logger().removeHandler(_default_handler  )





def 	__lowerCamelCase							():
					_configure_library_root_logger()

					assert _default_handler is not None
					_get_library_root_logger().addHandler(_default_handler  )





def 	__lowerCamelCase							(UpperCAmelCase__     :							logging.Handler  ):
					_configure_library_root_logger()

					assert handler is not None
					_get_library_root_logger().addHandler(UpperCAmelCase__  )





def 	__lowerCamelCase							(UpperCAmelCase__     :							logging.Handler  ):
					_configure_library_root_logger()

					assert handler is not None and handler not in _get_library_root_logger().handlers
					_get_library_root_logger().removeHandler(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					_configure_library_root_logger()
					SCREAMING_SNAKE_CASE    			=       False





def 	__lowerCamelCase							():
					_configure_library_root_logger()
					SCREAMING_SNAKE_CASE    			=       True





def 	__lowerCamelCase							():
					SCREAMING_SNAKE_CASE    			=       _get_library_root_logger().handlers

					for handler in handlers:
										SCREAMING_SNAKE_CASE    			=       logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"  )
										handler.setFormatter(UpperCAmelCase__  )





def 	__lowerCamelCase							():
					SCREAMING_SNAKE_CASE    			=       _get_library_root_logger().handlers

					for handler in handlers:
										handler.setFormatter(UpperCAmelCase__  )





def 	__lowerCamelCase							(self     :							str      , *UpperCAmelCase__     :							Union[str, Any]      , **UpperCAmelCase__     :							List[str]  ):
					SCREAMING_SNAKE_CASE    			=       os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS"      , UpperCAmelCase__  )
					if no_advisory_warnings:
										return
					self.warning(*UpperCAmelCase__      , **UpperCAmelCase__  )


_lowerCamelCase					:   str							=		warning_advice





@functools.lru_cache(UpperCAmelCase__  )
def 	__lowerCamelCase							(self     :							List[str]      , *UpperCAmelCase__     :							Tuple      , **UpperCAmelCase__     :							int  ):
					self.warning(*UpperCAmelCase__      , **UpperCAmelCase__  )


_lowerCamelCase					:   Dict							=		warning_once


class 						lowercase    :




							def __init__(						self   :					List[Any]	,							*_UpperCamelCase   :					Union[str, Any]	,							**_UpperCamelCase   :					str      )					->				List[Any]:  # pylint: disable=unused-argument



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       args[0] if args else None




							def __iter__(						self   :					Optional[Any]      )					->				str:



												'''simple docstring'''

												return iter(self._iterator      )




							def __getattr__(						self   :					List[str]	,							_UpperCamelCase   :					Any      )					->				List[Any]:



												'''simple docstring'''

												def empty_fn(*_UpperCamelCase   :					List[str]	,							**_UpperCamelCase   :					Union[str, Any]      ):  # pylint: disable=unused-argument
																	return

												return empty_fn




							def __enter__(						self   :					Any      )					->				Optional[Any]:



												'''simple docstring'''

												return self





							def __exit__(						self   :					Optional[Any]	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					List[str]      )					->				Union[str, Any]:



												'''simple docstring'''

												return



class 						lowercase    :




							def __call__(						self   :					Union[str, Any]	,							*_UpperCamelCase   :					Optional[Any]	,							**_UpperCamelCase   :					Tuple      )					->				Tuple:



												'''simple docstring'''

												if _tqdm_active:
																	return tqdm_lib.tqdm(*_UpperCamelCase	,							**_UpperCamelCase      )
												else:
																	return EmptyTqdm(*_UpperCamelCase	,							**_UpperCamelCase      )




							def 	__snake_case(						self   :					Dict	,							*_UpperCamelCase   :					Dict	,							**_UpperCamelCase   :					Union[str, Any]      )					->				Union[str, Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       None
												if _tqdm_active:
																	return tqdm_lib.tqdm.set_lock(*_UpperCamelCase	,							**_UpperCamelCase      )





							def 	__snake_case(						self   :					Optional[int]      )					->				Union[str, Any]:



												'''simple docstring'''

												if _tqdm_active:
																	return tqdm_lib.tqdm.get_lock()



_lowerCamelCase					:   Union[str, Any]							=		_tqdm_cls()





def 	__lowerCamelCase							():
					global _tqdm_active
					return bool(_tqdm_active  )





def 	__lowerCamelCase							():
					global _tqdm_active
					SCREAMING_SNAKE_CASE    			=       True
					hf_hub_utils.enable_progress_bars()





def 	__lowerCamelCase							():
					global _tqdm_active
					SCREAMING_SNAKE_CASE    			=       False
					hf_hub_utils.disable_progress_bars()




