import unittest

from transformers import BertGenerationConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import BertGenerationDecoder, BertGenerationEncoder


class 						lowercase    :




							def __init__(						self   :					Dict	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					Union[str, Any]=13	,							_UpperCamelCase   :					Any=7	,							_UpperCamelCase   :					Optional[Any]=True	,							_UpperCamelCase   :					Any=True	,							_UpperCamelCase   :					str=99	,							_UpperCamelCase   :					str=32	,							_UpperCamelCase   :					Optional[int]=5	,							_UpperCamelCase   :					Tuple=4	,							_UpperCamelCase   :					Optional[int]=37	,							_UpperCamelCase   :					Optional[Any]="gelu"	,							_UpperCamelCase   :					Dict=0.1	,							_UpperCamelCase   :					List[Any]=0.1	,							_UpperCamelCase   :					Optional[int]=50	,							_UpperCamelCase   :					List[str]=0.0_2	,							_UpperCamelCase   :					Optional[Any]=True	,							_UpperCamelCase   :					str=None	,							)					->				Optional[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       parent
												SCREAMING_SNAKE_CASE    			=       batch_size
												SCREAMING_SNAKE_CASE    			=       seq_length
												SCREAMING_SNAKE_CASE    			=       is_training
												SCREAMING_SNAKE_CASE    			=       use_input_mask
												SCREAMING_SNAKE_CASE    			=       vocab_size
												SCREAMING_SNAKE_CASE    			=       hidden_size
												SCREAMING_SNAKE_CASE    			=       num_hidden_layers
												SCREAMING_SNAKE_CASE    			=       num_attention_heads
												SCREAMING_SNAKE_CASE    			=       intermediate_size
												SCREAMING_SNAKE_CASE    			=       hidden_act
												SCREAMING_SNAKE_CASE    			=       hidden_dropout_prob
												SCREAMING_SNAKE_CASE    			=       attention_probs_dropout_prob
												SCREAMING_SNAKE_CASE    			=       max_position_embeddings
												SCREAMING_SNAKE_CASE    			=       initializer_range
												SCREAMING_SNAKE_CASE    			=       use_labels
												SCREAMING_SNAKE_CASE    			=       scope




							def 	__snake_case(						self   :					Dict      )					->				int:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       ids_tensor([self.batch_size, self.seq_length]	,							self.vocab_size      )

												SCREAMING_SNAKE_CASE    			=       None
												if self.use_input_mask:
																	SCREAMING_SNAKE_CASE    			=       random_attention_mask([self.batch_size, self.seq_length]      )

												if self.use_labels:
																	SCREAMING_SNAKE_CASE    			=       ids_tensor([self.batch_size, self.seq_length]	,							self.vocab_size      )

												SCREAMING_SNAKE_CASE    			=       self.get_config()

												return config, input_ids, input_mask, token_labels




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



												'''simple docstring'''

												return BertGenerationConfig(
												    vocab_size=self.vocab_size	,							hidden_size=self.hidden_size	,							num_hidden_layers=self.num_hidden_layers	,							num_attention_heads=self.num_attention_heads	,							intermediate_size=self.intermediate_size	,							hidden_act=self.hidden_act	,							hidden_dropout_prob=self.hidden_dropout_prob	,							attention_probs_dropout_prob=self.attention_probs_dropout_prob	,							max_position_embeddings=self.max_position_embeddings	,							is_decoder=_UpperCamelCase	,							initializer_range=self.initializer_range	,							)




							def 	__snake_case(						self   :					Any      )					->				str:



												'''simple docstring'''

												(
												    (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   
												)    			=       self.prepare_config_and_inputs()

												SCREAMING_SNAKE_CASE    			=       True
												SCREAMING_SNAKE_CASE    			=       floats_tensor([self.batch_size, self.seq_length, self.hidden_size]      )
												SCREAMING_SNAKE_CASE    			=       ids_tensor([self.batch_size, self.seq_length]	,							vocab_size=2      )

												return (
												    config,
												    input_ids,
												    input_mask,
												    token_labels,
												    encoder_hidden_states,
												    encoder_attention_mask,
												)




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationEncoder(config=_UpperCamelCase      )
												model.to(_UpperCamelCase      )
												model.eval()
												SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase	,							attention_mask=_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
												self.parent.assertEqual(result.last_hidden_state.shape	,							(self.batch_size, self.seq_length, self.hidden_size)      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       True
												SCREAMING_SNAKE_CASE    			=       BertGenerationEncoder(config=_UpperCamelCase      )
												model.to(_UpperCamelCase      )
												model.eval()
												SCREAMING_SNAKE_CASE    			=       model(
												    _UpperCamelCase	,							attention_mask=_UpperCamelCase	,							encoder_hidden_states=_UpperCamelCase	,							encoder_attention_mask=_UpperCamelCase	,							)
												SCREAMING_SNAKE_CASE    			=       model(
												    _UpperCamelCase	,							attention_mask=_UpperCamelCase	,							encoder_hidden_states=_UpperCamelCase	,							)
												self.parent.assertEqual(result.last_hidden_state.shape	,							(self.batch_size, self.seq_length, self.hidden_size)      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       True
												SCREAMING_SNAKE_CASE    			=       True
												SCREAMING_SNAKE_CASE    			=       BertGenerationDecoder(config=_UpperCamelCase      ).to(_UpperCamelCase      ).eval()

												# first forward pass
												SCREAMING_SNAKE_CASE    			=       model(
												    _UpperCamelCase	,							attention_mask=_UpperCamelCase	,							encoder_hidden_states=_UpperCamelCase	,							encoder_attention_mask=_UpperCamelCase	,							use_cache=_UpperCamelCase	,							)
												SCREAMING_SNAKE_CASE    			=       outputs.past_key_values

												# create hypothetical multiple next token and extent to next_input_ids
												SCREAMING_SNAKE_CASE    			=       ids_tensor((self.batch_size, 3)	,							config.vocab_size      )
												SCREAMING_SNAKE_CASE    			=       ids_tensor((self.batch_size, 3)	,							vocab_size=2      )

												# append to next input_ids and
												SCREAMING_SNAKE_CASE    			=       torch.cat([input_ids, next_tokens]	,							dim=-1      )
												SCREAMING_SNAKE_CASE    			=       torch.cat([input_mask, next_mask]	,							dim=-1      )

												SCREAMING_SNAKE_CASE    			=       model(
												    _UpperCamelCase	,							attention_mask=_UpperCamelCase	,							encoder_hidden_states=_UpperCamelCase	,							encoder_attention_mask=_UpperCamelCase	,							output_hidden_states=_UpperCamelCase	,							)["hidden_states"][0]
												SCREAMING_SNAKE_CASE    			=       model(
												    _UpperCamelCase	,							attention_mask=_UpperCamelCase	,							encoder_hidden_states=_UpperCamelCase	,							encoder_attention_mask=_UpperCamelCase	,							past_key_values=_UpperCamelCase	,							output_hidden_states=_UpperCamelCase	,							)["hidden_states"][0]

												# select random slice
												SCREAMING_SNAKE_CASE    			=       ids_tensor((1,)	,							output_from_past.shape[-1]      ).item()
												SCREAMING_SNAKE_CASE    			=       output_from_no_past[:, -3:, random_slice_idx].detach()
												SCREAMING_SNAKE_CASE    			=       output_from_past[:, :, random_slice_idx].detach()

												self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]      )

												# test that outputs are equal for slice
												self.parent.assertTrue(torch.allclose(_UpperCamelCase	,							_UpperCamelCase	,							atol=1e-3      )      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationDecoder(_UpperCamelCase      )
												model.to(_UpperCamelCase      )
												model.eval()
												SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase	,							attention_mask=_UpperCamelCase	,							labels=_UpperCamelCase      )
												self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.seq_length, self.vocab_size)      )





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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE    			=       self.prepare_config_and_inputs()
												SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask}
												return config, inputs_dict



@require_torch
class 						lowercase    (     a				,       a				,       a				,       unittest.TestCase     ):
							lowercase__						:       str								=							(BertGenerationEncoder, BertGenerationDecoder) if is_torch_available() else ()
							lowercase__						:       Dict								=							(BertGenerationDecoder,) if is_torch_available() else ()
							lowercase__						:       str								=							(
							    {"""feature-extraction""": BertGenerationEncoder, """text-generation""": BertGenerationDecoder}
							    if is_torch_available()
							    else {}
							)




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationEncoderTester(self      )
												SCREAMING_SNAKE_CASE    			=       ConfigTester(self	,							config_class=_UpperCamelCase	,							hidden_size=37      )




							def 	__snake_case(						self   :					Dict      )					->				Any:



												'''simple docstring'''

												self.config_tester.run_common_tests()




							def 	__snake_case(						self   :					Tuple      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE			,   SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												SCREAMING_SNAKE_CASE    			=       "bert"
												self.model_tester.create_and_check_model(_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_model_as_decoder(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_decoder_model_past_large_inputs(*_UpperCamelCase      )




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



												'''simple docstring'''

												(
												    (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   (
												    SCREAMING_SNAKE_CASE
												)			,   
												)    			=       self.model_tester.prepare_config_and_inputs_for_decoder()

												SCREAMING_SNAKE_CASE    			=       None

												self.model_tester.create_and_check_model_as_decoder(
												    _UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase	,							)




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_for_causal_lm(*_UpperCamelCase      )





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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationEncoder.from_pretrained("google/bert_for_seq_generation_L-24_bbc_encoder"      )
												self.assertIsNotNone(_UpperCamelCase      )



@require_torch
class 						lowercase    (     unittest.TestCase     ):




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationEncoder.from_pretrained("google/bert_for_seq_generation_L-24_bbc_encoder"      )
												SCREAMING_SNAKE_CASE    			=       torch.tensor([[101, 7_592, 1_010, 2_026, 3_899, 2_003, 10_140, 102]]      )
												with torch.no_grad():
																	SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )[0]
												SCREAMING_SNAKE_CASE    			=       torch.Size([1, 8, 1_024]      )
												self.assertEqual(output.shape	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       torch.tensor(
												    [[[0.1_7_7_5, 0.0_0_8_3, -0.0_3_2_1], [1.6_0_0_2, 0.1_2_8_7, 0.3_9_1_2], [2.1_4_7_3, 0.5_7_9_1, 0.6_0_6_6]]]      )
												self.assertTrue(torch.allclose(output[:, :3, :3]	,							_UpperCamelCase	,							atol=1e-4      )      )



@require_torch
class 						lowercase    (     unittest.TestCase     ):




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       BertGenerationDecoder.from_pretrained("google/bert_for_seq_generation_L-24_bbc_encoder"      )
												SCREAMING_SNAKE_CASE    			=       torch.tensor([[101, 7_592, 1_010, 2_026, 3_899, 2_003, 10_140, 102]]      )
												with torch.no_grad():
																	SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )[0]
												SCREAMING_SNAKE_CASE    			=       torch.Size([1, 8, 50_358]      )
												self.assertEqual(output.shape	,							_UpperCamelCase      )
												SCREAMING_SNAKE_CASE    			=       torch.tensor(
												    [[[-0.5_7_8_8, -2.5_9_9_4, -3.7_0_5_4], [0.0_4_3_8, 4.7_9_9_7, 1.8_7_9_5], [1.5_8_6_2, 6.6_4_0_9, 4.4_6_3_8]]]      )
												self.assertTrue(torch.allclose(output[:, :3, :3]	,							_UpperCamelCase	,							atol=1e-4      )      )





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()




