

from __future__ import annotations

import copy
import inspect
import json
import math
import os
import tempfile
import unittest
from importlib import import_module

import numpy as np

from transformers import ViTMAEConfig
from transformers.file_utils import cached_property, is_tf_available, is_vision_available
from transformers.testing_utils import require_tf, require_vision, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import tensorflow as tf

		from transformers import TFViTMAEForPreTraining, TFViTMAEModel


if is_vision_available():
		from PIL import Image

		from transformers import ViTImageProcessor







class 					__lowercase  :





							"""simple docstring"""

							def __init__(					self    ,						__UpperCAmelCase    ,						__UpperCAmelCase=13    ,						__UpperCAmelCase=30    ,						__UpperCAmelCase=2    ,						__UpperCAmelCase=3    ,						__UpperCAmelCase=True    ,						__UpperCAmelCase=True    ,						__UpperCAmelCase=32    ,						__UpperCAmelCase=2    ,						__UpperCAmelCase=4    ,						__UpperCAmelCase=37    ,						__UpperCAmelCase="gelu"    ,						__UpperCAmelCase=0.1    ,						__UpperCAmelCase=0.1    ,						__UpperCAmelCase=10    ,						__UpperCAmelCase=0.0_2    ,						__UpperCAmelCase=3    ,						__UpperCAmelCase=0.6    ,						__UpperCAmelCase=None    ,						)		->       Optional[Any]:
														A      :					List[str]      		=					parent
														A      :					Optional[int]      		=					batch_size
														A      :					str      		=					image_size
														A      :					Optional[Any]      		=					patch_size
														A      :					Optional[int]      		=					num_channels
														A      :					Union[str, Any]      		=					is_training
														A      :					int      		=					use_labels
														A      :					Union[str, Any]      		=					hidden_size
														A      :					Optional[Any]      		=					num_hidden_layers
														A      :					str      		=					num_attention_heads
														A      :					str      		=					intermediate_size
														A      :					Dict      		=					hidden_act
														A      :					Optional[int]      		=					hidden_dropout_prob
														A      :					Optional[int]      		=					attention_probs_dropout_prob
														A      :					Optional[Any]      		=					type_sequence_label_size
														A      :					List[str]      		=					initializer_range
														A      :					Dict      		=					mask_ratio
														A      :					str      		=					scope

														# in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
														# (we add 1 for the [CLS] token)
														A      :					Dict      		=					(image_size // patch_size) ** 2
														A      :					int      		=					int(math.ceil((1 - mask_ratio) * (num_patches + 1)						)						)




							def       snake_case			(					self						)		->       int:
														A      :					Dict      		=					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

														A      :					int      		=					None
														if self.use_labels:
																					A      :					Union[str, Any]      		=					ids_tensor([self.batch_size]    ,						self.type_sequence_label_size						)

														A      :					Optional[int]      		=					self.get_config()

														return config, pixel_values, labels




							def       snake_case			(					self						)		->       List[str]:
														return ViTMAEConfig(
														    image_size=self.image_size    ,						patch_size=self.patch_size    ,						num_channels=self.num_channels    ,						hidden_size=self.hidden_size    ,						num_hidden_layers=self.num_hidden_layers    ,						num_attention_heads=self.num_attention_heads    ,						intermediate_size=self.intermediate_size    ,						decoder_hidden_size=self.hidden_size    ,						decoder_num_hidden_layers=self.num_hidden_layers    ,						decoder_num_attention_heads=self.num_attention_heads    ,						decoder_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    ,						is_decoder=__UpperCAmelCase    ,						initializer_range=self.initializer_range    ,						mask_ratio=self.mask_ratio    ,						)




							def       snake_case			(					self    ,						__UpperCAmelCase    ,						__UpperCAmelCase    ,						__UpperCAmelCase						)		->       List[str]:
														A      :					str      		=					TFViTMAEModel(config=__UpperCAmelCase						)
														A      :					Optional[Any]      		=					model(__UpperCAmelCase    ,						training=__UpperCAmelCase						)
														self.parent.assertEqual(result.last_hidden_state.shape    ,						(self.batch_size, self.seq_length, self.hidden_size)						)




							def       snake_case			(					self    ,						__UpperCAmelCase    ,						__UpperCAmelCase    ,						__UpperCAmelCase						)		->       Dict:
														A      :					Dict      		=					TFViTMAEForPreTraining(__UpperCAmelCase						)
														A      :					str      		=					model(__UpperCAmelCase    ,						training=__UpperCAmelCase						)
														# expected sequence length = num_patches
														A      :					Optional[Any]      		=					(self.image_size // self.patch_size) ** 2
														A      :					str      		=					self.patch_size**2 * self.num_channels
														self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, num_patches, expected_num_channels)						)

														# test greyscale images
														A      :					str      		=					1
														A      :					Optional[Any]      		=					TFViTMAEForPreTraining(__UpperCAmelCase						)

														A      :					Optional[int]      		=					floats_tensor([self.batch_size, 1, self.image_size, self.image_size]						)
														A      :					Optional[Any]      		=					model(__UpperCAmelCase    ,						training=__UpperCAmelCase						)
														A      :					List[str]      		=					self.patch_size**2
														self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, num_patches, expected_num_channels)						)






							def       snake_case			(					self						)		->       str:
														A      :					Dict      		=					self.prepare_config_and_inputs()
														((A)		,		(A)		,		(A))      :					Optional[Any]      		=					config_and_inputs
														A      :					Dict      		=					{'''pixel_values''': pixel_values}
														return config, inputs_dict







@require_tf
class 					__lowercase  (						_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       unittest.TestCase				):





							"""simple docstring"""

							UpperCAmelCase_						:		Optional[Any]								=	(TFViTMAEModel, TFViTMAEForPreTraining) if is_tf_available() else ()
							UpperCAmelCase_						:		Optional[int]								=	{'''feature-extraction''': TFViTMAEModel} if is_tf_available() else {}

							UpperCAmelCase_						:		Any								=	False
							UpperCAmelCase_						:		List[Any]								=	False
							UpperCAmelCase_						:		List[str]								=	False
							UpperCAmelCase_						:		int								=	False




							def       snake_case			(					self						)		->       Any:
														A      :					Any      		=					TFViTMAEModelTester(self						)
														A      :					Optional[Any]      		=					ConfigTester(self    ,						config_class=__UpperCAmelCase    ,						has_text_modality=__UpperCAmelCase    ,						hidden_size=37						)




							def       snake_case			(					self						)		->       Tuple:
														self.config_tester.run_common_tests()




							@unittest.skip(reason='''ViTMAE does not use inputs_embeds'''						)
							def       snake_case			(					self						)		->       Tuple:
														pass




							def       snake_case			(					self						)		->       Optional[int]:
														A		,		A      :					Any      		=					self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					A      :					List[str]      		=					model_class(__UpperCAmelCase						)
																					self.assertIsInstance(model.get_input_embeddings()    ,						(tf.keras.layers.Layer)						)
																					A      :					Any      		=					model.get_output_embeddings()
																					self.assertTrue(x is None or isinstance(__UpperCAmelCase    ,						tf.keras.layers.Layer						)						)




							def       snake_case			(					self						)		->       Dict:
														A		,		A      :					int      		=					self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					A      :					str      		=					model_class(__UpperCAmelCase						)
																					A      :					Optional[int]      		=					inspect.signature(model.call						)
																					# signature.parameters is an OrderedDict => so arg_names order is deterministic
																					A      :					Union[str, Any]      		=					[*signature.parameters.keys()]

																					A      :					List[str]      		=					['''pixel_values''']
																					self.assertListEqual(arg_names[:1]    ,						__UpperCAmelCase						)




							def       snake_case			(					self						)		->       str:
														A      :					Optional[Any]      		=					self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*__UpperCAmelCase						)




							def       snake_case			(					self						)		->       str:
														A      :					int      		=					self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_pretraining(*__UpperCAmelCase						)




							def       snake_case			(					self						)		->       List[str]:
														# make the mask reproducible
														np.random.seed(2						)

														A		,		A      :					Dict      		=					self.model_tester.prepare_config_and_inputs_for_common()

														A      :					Tuple      		=					int((config.image_size // config.patch_size) ** 2						)
														A      :					Optional[Any]      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

														for model_class in self.all_model_classes:
																					A      :					Dict      		=					model_class(__UpperCAmelCase						)
																					A      :					Dict      		=					self._prepare_for_class(__UpperCAmelCase    ,						__UpperCAmelCase						)

																					A      :					List[Any]      		=					model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)

																					A      :					Union[str, Any]      		=					copy.deepcopy(self._prepare_for_class(__UpperCAmelCase    ,						__UpperCAmelCase						)						)
																					A      :					Optional[Any]      		=					model(**__UpperCAmelCase    ,						noise=__UpperCAmelCase						)
																					A      :					Any      		=					outputs_dict[0].numpy()
																					A      :					Optional[Any]      		=					outputs_keywords[0].numpy()

																					self.assertLess(np.sum(np.abs(output_dict - output_keywords						)						)    ,						1E-6						)




							def       snake_case			(					self						)		->       Dict:
														# make the mask reproducible
														np.random.seed(2						)

														A		,		A      :					Optional[int]      		=					self.model_tester.prepare_config_and_inputs_for_common()

														A      :					Dict      		=					int((config.image_size // config.patch_size) ** 2						)
														A      :					Optional[Any]      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

														def prepare_numpy_arrays(__UpperCAmelCase						):
																					A      :					Dict      		=					{}
																					for k, v in inputs_dict.items():
																												if tf.is_tensor(__UpperCAmelCase						):
																																			A      :					int      		=					v.numpy()
																												else:
																																			A      :					int      		=					np.array(__UpperCAmelCase						)

																					return inputs_np_dict

														for model_class in self.all_model_classes:
																					A      :					Dict      		=					model_class(__UpperCAmelCase						)

																					A      :					List[str]      		=					self._prepare_for_class(__UpperCAmelCase    ,						__UpperCAmelCase						)
																					A      :					Optional[Any]      		=					prepare_numpy_arrays(__UpperCAmelCase						)

																					A      :					Dict      		=					model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)
																					A      :					List[str]      		=					model(**__UpperCAmelCase    ,						noise=__UpperCAmelCase						)
																					self.assert_outputs_same(__UpperCAmelCase    ,						__UpperCAmelCase						)




							def       snake_case			(					self    ,						__UpperCAmelCase    ,						__UpperCAmelCase    ,						__UpperCAmelCase						)		->       List[Any]:
														# make masks reproducible
														np.random.seed(2						)

														A      :					Optional[Any]      		=					int((tf_model.config.image_size // tf_model.config.patch_size) ** 2						)
														A      :					int      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)
														A      :					List[str]      		=					tf.constant(__UpperCAmelCase						)

														# Add `noise` argument.
														# PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
														A      :					Union[str, Any]      		=					tf_noise

														super().check_pt_tf_models(__UpperCAmelCase    ,						__UpperCAmelCase    ,						__UpperCAmelCase						)




							def       snake_case			(					self						)		->       Any:
														# make mask reproducible
														np.random.seed(2						)

														A		,		A      :					List[Any]      		=					self.model_tester.prepare_config_and_inputs_for_common()

														A      :					str      		=					{
														    module_member
														    for model_class in self.all_model_classes
														    for module in (import_module(model_class.__module__						),)
														    for module_member_name in dir(__UpperCAmelCase						)
														    if module_member_name.endswith('''MainLayer'''						)
														    # This condition is required, since `modeling_tf_clip.py` has 3 classes whose names end with `MainLayer`.
														    and module_member_name[: -len('''MainLayer'''						)] == model_class.__name__[: -len('''Model'''						)]
														    for module_member in (getattr(__UpperCAmelCase    ,						__UpperCAmelCase						),)
														    if isinstance(__UpperCAmelCase    ,						__UpperCAmelCase						)
														    and tf.keras.layers.Layer in module_member.__bases__
														    and getattr(__UpperCAmelCase    ,						'''_keras_serializable'''    ,						__UpperCAmelCase						)
														}

														A      :					Union[str, Any]      		=					int((config.image_size // config.patch_size) ** 2						)
														A      :					Tuple      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)
														A      :					List[Any]      		=					tf.convert_to_tensor(__UpperCAmelCase						)
														inputs_dict.update({'''noise''': noise}						)

														for main_layer_class in tf_main_layer_classes:
																					A      :					str      		=					main_layer_class(__UpperCAmelCase						)

																					A      :					Tuple      		=					{
																					    name: tf.keras.Input(tensor.shape[1:]    ,						dtype=tensor.dtype						) for name, tensor in inputs_dict.items()
																					}

																					A      :					Any      		=					tf.keras.Model(__UpperCAmelCase    ,						outputs=main_layer(__UpperCAmelCase						)						)
																					A      :					List[Any]      		=					model(__UpperCAmelCase						)

																					with tempfile.TemporaryDirectory() as tmpdirname:
																												A      :					Any      		=					os.path.join(__UpperCAmelCase    ,						'''keras_model.h5'''						)
																												model.save(__UpperCAmelCase						)
																												A      :					Optional[int]      		=					tf.keras.models.load_model(
																												    __UpperCAmelCase    ,						custom_objects={main_layer_class.__name__: main_layer_class}						)
																												assert isinstance(__UpperCAmelCase    ,						tf.keras.Model						)
																												A      :					Dict      		=					model(__UpperCAmelCase						)
																												self.assert_outputs_same(__UpperCAmelCase    ,						__UpperCAmelCase						)




							@slow
							def       snake_case			(					self						)		->       Tuple:
														# make mask reproducible
														np.random.seed(2						)

														A		,		A      :					List[str]      		=					self.model_tester.prepare_config_and_inputs_for_common()

														A      :					Any      		=					int((config.image_size // config.patch_size) ** 2						)
														A      :					Optional[int]      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

														for model_class in self.all_model_classes:
																					A      :					Optional[Any]      		=					model_class(__UpperCAmelCase						)
																					A      :					List[Any]      		=					self._prepare_for_class(__UpperCAmelCase    ,						__UpperCAmelCase						)
																					A      :					Tuple      		=					model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)

																					if model_class.__name__ == "TFViTMAEModel":
																												A      :					List[Any]      		=					outputs.last_hidden_state.numpy()
																												A      :					Dict      		=					0
																					else:
																												A      :					Tuple      		=					outputs.logits.numpy()
																												A      :					List[Any]      		=					0

																					with tempfile.TemporaryDirectory() as tmpdirname:
																												model.save_pretrained(__UpperCAmelCase    ,						saved_model=__UpperCAmelCase						)
																												A      :					Tuple      		=					model_class.from_pretrained(__UpperCAmelCase						)
																												A      :					Tuple      		=					model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)

																												if model_class.__name__ == "TFViTMAEModel":
																																			A      :					int      		=					after_outputs['''last_hidden_state'''].numpy()
																																			A      :					List[Any]      		=					0
																												else:
																																			A      :					Union[str, Any]      		=					after_outputs['''logits'''].numpy()
																																			A      :					Any      		=					0

																												A      :					List[Any]      		=					np.amax(np.abs(out_a - out_a						)						)
																												self.assertLessEqual(__UpperCAmelCase    ,						1E-5						)




							def       snake_case			(					self						)		->       List[Any]:
														# make mask reproducible
														np.random.seed(2						)

														A		,		A      :					str      		=					self.model_tester.prepare_config_and_inputs_for_common()

														A      :					Union[str, Any]      		=					int((config.image_size // config.patch_size) ** 2						)
														A      :					Optional[int]      		=					np.random.uniform(size=(self.model_tester.batch_size, num_patches)						)

														for model_class in self.all_model_classes:
																					A      :					int      		=					model_class(__UpperCAmelCase						)
																					A      :					Tuple      		=					self._prepare_for_class(__UpperCAmelCase    ,						__UpperCAmelCase						)

																					A      :					str      		=					model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)
																					A      :					int      		=					model.get_config()
																					# make sure that returned config is jsonifiable, which is required by keras
																					json.dumps(__UpperCAmelCase						)
																					A      :					Any      		=					model_class.from_config(model.get_config()						)
																					# make sure it also accepts a normal config
																					A      :					Optional[Any]      		=					model_class.from_config(model.config						)
																					A      :					int      		=					new_model(__UpperCAmelCase						)  # Build model
																					new_model.set_weights(model.get_weights()						)
																					A      :					Optional[Any]      		=					new_model(__UpperCAmelCase    ,						noise=__UpperCAmelCase						)

																					self.assert_outputs_same(__UpperCAmelCase    ,						__UpperCAmelCase						)




							@unittest.skip(
							    reason='''ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load
    to get deterministic results.'''						)
							def       snake_case			(					self						)		->       Dict:
														pass




							@unittest.skip(reason='''ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load'''						)
							def       snake_case			(					self						)		->       Union[str, Any]:
														pass






							@slow
							def       snake_case			(					self						)		->       Union[str, Any]:
														A      :					Any      		=					TFViTMAEModel.from_pretrained('''google/vit-base-patch16-224'''						)
														self.assertIsNotNone(__UpperCAmelCase						)






def        snake_case__		(    ):
							A      :					Dict      		=					Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''		)
							return image







@require_tf
@require_vision
class 					__lowercase  (						unittest.TestCase				):





							"""simple docstring"""

							@cached_property
							def       snake_case			(					self						)		->       str:
														return ViTImageProcessor.from_pretrained('''facebook/vit-mae-base'''						) if is_vision_available() else None






							@slow
							def       snake_case			(					self						)		->       List[Any]:
														# make random mask reproducible across the PT and TF model
														np.random.seed(2						)

														A      :					List[str]      		=					TFViTMAEForPreTraining.from_pretrained('''facebook/vit-mae-base'''						)

														A      :					int      		=					self.default_image_processor
														A      :					str      		=					prepare_img()
														A      :					Any      		=					image_processor(images=__UpperCAmelCase    ,						return_tensors='''tf'''						)

														# prepare a noise vector that will be also used for testing the TF model
														# (this way we can ensure that the PT and TF models operate on the same inputs)
														A      :					Tuple      		=					ViTMAEConfig()
														A      :					Optional[Any]      		=					int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2						)
														A      :					Any      		=					np.random.uniform(size=(1, num_patches)						)

														# forward pass
														A      :					Optional[int]      		=					model(**__UpperCAmelCase    ,						noise=__UpperCAmelCase						)

														# verify the logits
														A      :					List[Any]      		=					tf.convert_to_tensor([1, 1_96, 7_68]						)
														self.assertEqual(outputs.logits.shape    ,						__UpperCAmelCase						)

														A      :					Union[str, Any]      		=					tf.convert_to_tensor(
														    [[-0.0_5_4_8, -1.7_0_2_3, -0.9_3_2_5], [0.3_7_2_1, -0.5_6_7_0, -0.2_2_3_3], [0.8_2_3_5, -1.3_8_7_8, -0.3_5_2_4]]						)

														tf.debugging.assert_near(outputs.logits[0, :3, :3]    ,						__UpperCAmelCase    ,						atol=1E-4						)









import os
import unittest

from huggingface_hub.utils import are_progress_bars_disabled

import transformers.models.bart.tokenization_bart
from transformers import logging
from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context
from transformers.utils.logging import disable_progress_bar, enable_progress_bar







class 					__lowercase  (						unittest.TestCase				):





							"""simple docstring"""

							def       snake_case			(					self						)		->       Union[str, Any]:
														A      :					Dict      		=					logging.get_logger()

														# the current default level is logging.WARNING
														A      :					List[Any]      		=					logging.get_verbosity()

														logging.set_verbosity_error()
														self.assertEqual(logger.getEffectiveLevel()    ,						logging.get_verbosity()						)

														logging.set_verbosity_warning()
														self.assertEqual(logger.getEffectiveLevel()    ,						logging.get_verbosity()						)

														logging.set_verbosity_info()
														self.assertEqual(logger.getEffectiveLevel()    ,						logging.get_verbosity()						)

														logging.set_verbosity_debug()
														self.assertEqual(logger.getEffectiveLevel()    ,						logging.get_verbosity()						)

														# restore to the original level
														logging.set_verbosity(__UpperCAmelCase						)




							def       snake_case			(					self						)		->       str:
														A      :					Any      		=					logging.get_verbosity()

														A      :					Optional[Any]      		=					logging.get_logger('''transformers.models.bart.tokenization_bart'''						)
														A      :					Tuple      		=					'''Testing 1, 2, 3'''

														# should be able to log warnings (if default settings weren't overridden by `pytest --log-level-all`)
														if level_origin <= logging.WARNING:
																					with CaptureLogger(__UpperCAmelCase						) as cl:
																												logger.warning(__UpperCAmelCase						)
																					self.assertEqual(cl.out    ,						msg + '''\n'''						)

														# this is setting the level for all of `transformers.*` loggers
														logging.set_verbosity_error()

														# should not be able to log warnings
														with CaptureLogger(__UpperCAmelCase						) as cl:
																					logger.warning(__UpperCAmelCase						)
														self.assertEqual(cl.out    ,						''''''						)

														# should be able to log warnings again
														logging.set_verbosity_warning()
														with CaptureLogger(__UpperCAmelCase						) as cl:
																					logger.warning(__UpperCAmelCase						)
														self.assertEqual(cl.out    ,						msg + '''\n'''						)

														# restore to the original level
														logging.set_verbosity(__UpperCAmelCase						)




							@mockenv(TRANSFORMERS_VERBOSITY='''error'''						)
							def       snake_case			(					self						)		->       Optional[int]:
														# reset for the env var to take effect, next time some logger call is made
														transformers.utils.logging._reset_library_root_logger()
														# this action activates the env var
														A      :					int      		=					logging.get_logger('''transformers.models.bart.tokenization_bart'''						)

														A      :					Any      		=					os.getenv('''TRANSFORMERS_VERBOSITY'''    ,						__UpperCAmelCase						)
														A      :					List[str]      		=					logging.log_levels[env_level_str]

														A      :					Optional[int]      		=					logging.get_verbosity()
														self.assertEqual(
														    __UpperCAmelCase    ,						__UpperCAmelCase    ,						f'TRANSFORMERS_VERBOSITY={env_level_str}/{env_level}, but internal verbosity is {current_level}'    ,						)

														# restore to the original level
														A      :					str      		=					''''''
														transformers.utils.logging._reset_library_root_logger()




							@mockenv(TRANSFORMERS_VERBOSITY='''super-error'''						)
							def       snake_case			(					self						)		->       Optional[int]:
														# reset for the env var to take effect, next time some logger call is made
														transformers.utils.logging._reset_library_root_logger()
														A      :					str      		=					logging.logging.getLogger()
														with CaptureLogger(__UpperCAmelCase						) as cl:
																					# this action activates the env var
																					logging.get_logger('''transformers.models.bart.tokenization_bart'''						)
														self.assertIn('''Unknown option TRANSFORMERS_VERBOSITY=super-error'''    ,						cl.out						)

														# no need to restore as nothing was changed






							def       snake_case			(					self						)		->       Optional[int]:
														# testing `logger.warning_advice()`
														transformers.utils.logging._reset_library_root_logger()

														A      :					Union[str, Any]      		=					logging.get_logger('''transformers.models.bart.tokenization_bart'''						)
														A      :					Optional[int]      		=					'''Testing 1, 2, 3'''

														with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS='''1'''						):
																					# nothing should be logged as env var disables this method
																					with CaptureLogger(__UpperCAmelCase						) as cl:
																												logger.warning_advice(__UpperCAmelCase						)
																					self.assertEqual(cl.out    ,						''''''						)

														with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS=''''''						):
																					# should log normally as TRANSFORMERS_NO_ADVISORY_WARNINGS is unset
																					with CaptureLogger(__UpperCAmelCase						) as cl:
																												logger.warning_advice(__UpperCAmelCase						)
																					self.assertEqual(cl.out    ,						msg + '''\n'''						)






def        snake_case__		(    ):
							disable_progress_bar()
							assert are_progress_bars_disabled()

							enable_progress_bar()
							assert not are_progress_bars_disabled()






