
from typing import Optional, Tuple, Union

import tensorflow as tf

from ...activations_tf import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_tf_outputs import (
    TFBaseModelOutputWithNoAttention,
    TFBaseModelOutputWithPoolingAndNoAttention,
    TFSequenceClassifierOutput,
)
from ...modeling_tf_utils import TFPreTrainedModel, TFSequenceClassificationLoss, keras_serializable, unpack_inputs
from ...tf_utils import shape_list
from ...utils import logging
from .configuration_regnet import RegNetConfig


lowerCamelCase_						: Optional[Any]         =  logging.get_logger(__name__)

# General docstring
lowerCamelCase_						: Tuple         =  """RegNetConfig"""

# Base docstring
lowerCamelCase_						: List[Any]         =  """facebook/regnet-y-040"""
lowerCamelCase_						: Any         =  [1, 10_88, 7, 7]

# Image classification docstring
lowerCamelCase_						: Optional[Any]         =  """facebook/regnet-y-040"""
lowerCamelCase_						: List[str]         =  """tabby, tabby cat"""

lowerCamelCase_						: Any         =  [
    """facebook/regnet-y-040""",
    # See all regnet models at https://huggingface.co/models?filter=regnet
]

class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Any						,	snake_case_ :       int						,	snake_case_ :       int = 3						,	snake_case_ :       int = 1						,	snake_case_ :       int = 1						,	snake_case_ :       Optional[str] = "relu"						,	**snake_case_ :       List[Any]						,	):
							super().__init__(**snake_case_      )
							# The padding and conv has been verified in
							# https://colab.research.google.com/gist/sayakpaul/854bc10eeaf21c9ee2119e0b9f3841a7/scratchpad.ipynb
							UpperCamelCase_:							int	=						tf.keras.layers.ZeroPaddingaD(padding=kernel_size // 2      )
							UpperCamelCase_:							Optional[Any]	=						tf.keras.layers.ConvaD(
							    filters=snake_case_						,	kernel_size=snake_case_						,	strides=snake_case_						,	padding="""VALID"""						,	groups=snake_case_						,	use_bias=snake_case_						,	name="""convolution"""						,	)
							UpperCamelCase_:							List[str]	=						tf.keras.layers.BatchNormalization(epsilon=1e-5						,	momentum=0.9						,	name="""normalization"""      )
							UpperCamelCase_:							Dict	=						ACTaFN[activation] if activation is not None else tf.identity




			def       lowerCAmelCase__	(       self :       str						,	snake_case_ :       Union[str, Any]      ):
							UpperCamelCase_:							Dict	=						self.convolution(self.padding(snake_case_      )      )
							UpperCamelCase_:							int	=						self.normalization(snake_case_      )
							UpperCamelCase_:							int	=						self.activation(snake_case_      )
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Union[str, Any]						,	snake_case_ :       RegNetConfig						,	**snake_case_ :       Any      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							Union[str, Any]	=						config.num_channels
							UpperCamelCase_:							List[Any]	=						TFRegNetConvLayer(
							    out_channels=config.embedding_size						,	kernel_size=3						,	stride=2						,	activation=config.hidden_act						,	name="""embedder"""						,	)




			def       lowerCAmelCase__	(       self :       Union[str, Any]						,	snake_case_ :       str      ):
							UpperCamelCase_:							str	=						shape_list(snake_case_      )[1]
							if tf.executing_eagerly() and num_channels != self.num_channels:
											raise ValueError(
											    """Make sure that the channel dimension of the pixel values match with the one set in the configuration."""      )

							# When running on CPU, `tf.keras.layers.Conv2D` doesn't support `NCHW` format.
							# So change the input format from `NCHW` to `NHWC`.
							# shape = (batch_size, in_height, in_width, in_channels=num_channels)
							UpperCamelCase_:							str	=						tf.transpose(snake_case_						,	perm=(0, 2, 3, 1)      )
							UpperCamelCase_:							str	=						self.embedder(snake_case_      )
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Union[str, Any]						,	snake_case_ :       int						,	snake_case_ :       int = 2						,	**snake_case_ :       Optional[Any]      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							str	=						tf.keras.layers.ConvaD(
							    filters=snake_case_						,	kernel_size=1						,	strides=snake_case_						,	use_bias=snake_case_						,	name="""convolution"""      )
							UpperCamelCase_:							int	=						tf.keras.layers.BatchNormalization(epsilon=1e-5						,	momentum=0.9						,	name="""normalization"""      )




			def       lowerCAmelCase__	(       self :       Any						,	snake_case_ :       tf.Tensor						,	snake_case_ :       bool = False      ):
							return self.normalization(self.convolution(snake_case_      )						,	training=snake_case_      )




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Tuple						,	snake_case_ :       int						,	snake_case_ :       int						,	**snake_case_ :       List[str]      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							str	=						tf.keras.layers.GlobalAveragePoolingaD(keepdims=snake_case_						,	name="""pooler"""      )
							UpperCamelCase_:							List[Any]	=						[
							    tf.keras.layers.ConvaD(filters=snake_case_						,	kernel_size=1						,	activation="""relu"""						,	name="""attention.0"""      ),
							    tf.keras.layers.ConvaD(filters=snake_case_						,	kernel_size=1						,	activation="""sigmoid"""						,	name="""attention.2"""      ),
							]




			def       lowerCAmelCase__	(       self :       List[Any]						,	snake_case_ :       Dict      ):
							# [batch_size, h, w, num_channels] -> [batch_size, 1, 1, num_channels]
							UpperCamelCase_:							List[str]	=						self.pooler(snake_case_      )
							for layer_module in self.attention:
											UpperCamelCase_:							Union[str, Any]	=						layer_module(snake_case_      )
							UpperCamelCase_:							Dict	=						hidden_state * pooled
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       str						,	snake_case_ :       RegNetConfig						,	snake_case_ :       int						,	snake_case_ :       int						,	snake_case_ :       int = 1						,	**snake_case_ :       Dict      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							List[str]	=						in_channels != out_channels or stride != 1
							UpperCamelCase_:							Tuple	=						max(1						,	out_channels // config.groups_width      )
							UpperCamelCase_:							Tuple	=						(
							    TFRegNetShortCut(snake_case_						,	stride=snake_case_						,	name="""shortcut"""      )
							    if should_apply_shortcut
							    else tf.keras.layers.Activation("""linear"""						,	name="""shortcut"""      )
							)
							# `self.layers` instead of `self.layer` because that is a reserved argument.
							UpperCamelCase_:							Any	=						[
							    TFRegNetConvLayer(snake_case_						,	kernel_size=1						,	activation=config.hidden_act						,	name="""layer.0"""      ),
							    TFRegNetConvLayer(
							        snake_case_						,	stride=snake_case_						,	groups=snake_case_						,	activation=config.hidden_act						,	name="""layer.1"""      ),
							    TFRegNetConvLayer(snake_case_						,	kernel_size=1						,	activation=snake_case_						,	name="""layer.2"""      ),
							]
							UpperCamelCase_:							Union[str, Any]	=						ACTaFN[config.hidden_act]




			def       lowerCAmelCase__	(       self :       List[Any]						,	snake_case_ :       Tuple      ):
							UpperCamelCase_:							Optional[Any]	=						hidden_state
							for layer_module in self.layers:
											UpperCamelCase_:							Union[str, Any]	=						layer_module(snake_case_      )
							UpperCamelCase_:							Optional[int]	=						self.shortcut(snake_case_      )
							hidden_state += residual
							UpperCamelCase_:							List[str]	=						self.activation(snake_case_      )
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Optional[Any]						,	snake_case_ :       RegNetConfig						,	snake_case_ :       int						,	snake_case_ :       int						,	snake_case_ :       int = 1						,	**snake_case_ :       List[Any]      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							Union[str, Any]	=						in_channels != out_channels or stride != 1
							UpperCamelCase_:							str	=						max(1						,	out_channels // config.groups_width      )
							UpperCamelCase_:							List[str]	=						(
							    TFRegNetShortCut(snake_case_						,	stride=snake_case_						,	name="""shortcut"""      )
							    if should_apply_shortcut
							    else tf.keras.layers.Activation("""linear"""						,	name="""shortcut"""      )
							)
							UpperCamelCase_:							str	=						[
							    TFRegNetConvLayer(snake_case_						,	kernel_size=1						,	activation=config.hidden_act						,	name="""layer.0"""      ),
							    TFRegNetConvLayer(
							        snake_case_						,	stride=snake_case_						,	groups=snake_case_						,	activation=config.hidden_act						,	name="""layer.1"""      ),
							    TFRegNetSELayer(snake_case_						,	reduced_channels=int(round(in_channels / 4      )      )						,	name="""layer.2"""      ),
							    TFRegNetConvLayer(snake_case_						,	kernel_size=1						,	activation=snake_case_						,	name="""layer.3"""      ),
							]
							UpperCamelCase_:							List[str]	=						ACTaFN[config.hidden_act]




			def       lowerCAmelCase__	(       self :       List[Any]						,	snake_case_ :       int      ):
							UpperCamelCase_:							Union[str, Any]	=						hidden_state
							for layer_module in self.layers:
											UpperCamelCase_:							str	=						layer_module(snake_case_      )
							UpperCamelCase_:							Optional[int]	=						self.shortcut(snake_case_      )
							hidden_state += residual
							UpperCamelCase_:							Optional[int]	=						self.activation(snake_case_      )
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       List[str]						,	snake_case_ :       RegNetConfig						,	snake_case_ :       int						,	snake_case_ :       int						,	snake_case_ :       int = 2						,	snake_case_ :       int = 2						,	**snake_case_ :       Any      ):
							super().__init__(**snake_case_      )

							UpperCamelCase_:							Dict	=						TFRegNetXLayer if config.layer_type == """x""" else TFRegNetYLayer
							UpperCamelCase_:							str	=						[
							    # downsampling is done in the first layer with stride of 2
							    layer(snake_case_						,	snake_case_						,	snake_case_						,	stride=snake_case_						,	name="""layers.0"""      ),
							    *[layer(snake_case_						,	snake_case_						,	snake_case_						,	name=f'''layers.{i+1}'''      ) for i in range(depth - 1      )],
							]




			def       lowerCAmelCase__	(       self :       List[Any]						,	snake_case_ :       List[Any]      ):
							for layer_module in self.layers:
											UpperCamelCase_:							Any	=						layer_module(snake_case_      )
							return hidden_state




class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			def __init__(       self :       Tuple						,	snake_case_ :       RegNetConfig						,	**snake_case_ :       Optional[int]      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							Any	=						[]
							# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
							self.stages.append(
							    TFRegNetStage(
							        snake_case_						,	config.embedding_size						,	config.hidden_sizes[0]						,	stride=2 if config.downsample_in_first_stage else 1						,	depth=config.depths[0]						,	name="""stages.0"""						,	)      )
							UpperCamelCase_:							Union[str, Any]	=						zip(config.hidden_sizes						,	config.hidden_sizes[1:]      )
							for i, ((in_channels, out_channels), depth) in enumerate(zip(snake_case_						,	config.depths[1:]      )      ):
											self.stages.append(TFRegNetStage(snake_case_						,	snake_case_						,	snake_case_						,	depth=snake_case_						,	name=f'''stages.{i+1}'''      )      )




			def       lowerCAmelCase__	(       self :       List[str]						,	snake_case_ :       tf.Tensor						,	snake_case_ :       bool = False						,	snake_case_ :       bool = True      ):
							UpperCamelCase_:							int	=						() if output_hidden_states else None

							for stage_module in self.stages:
											if output_hidden_states:
															UpperCamelCase_:							str	=						hidden_states + (hidden_state,)

											UpperCamelCase_:							List[Any]	=						stage_module(snake_case_      )

							if output_hidden_states:
											UpperCamelCase_:							Union[str, Any]	=						hidden_states + (hidden_state,)

							if not return_dict:
											return tuple(v for v in [hidden_state, hidden_states] if v is not None      )

							return TFBaseModelOutputWithNoAttention(last_hidden_state=snake_case_						,	hidden_states=snake_case_      )




@keras_serializable
class        _UpperCamelCase				(					tf.keras.layers.Layer  ):






			'''simple docstring'''

			__UpperCamelCase      :						Any					      = RegNetConfig

			def __init__(       self :       Dict						,	snake_case_ :       Union[str, Any]						,	**snake_case_ :       Tuple      ):
							super().__init__(**snake_case_      )
							UpperCamelCase_:							Optional[int]	=						config
							UpperCamelCase_:							Tuple	=						TFRegNetEmbeddings(snake_case_						,	name="""embedder"""      )
							UpperCamelCase_:							Union[str, Any]	=						TFRegNetEncoder(snake_case_						,	name="""encoder"""      )
							UpperCamelCase_:							Any	=						tf.keras.layers.GlobalAveragePoolingaD(keepdims=snake_case_						,	name="""pooler"""      )




			@unpack_inputs
			def       lowerCAmelCase__	(       self :       Optional[Any]						,	snake_case_ :       tf.Tensor						,	snake_case_ :       Optional[bool] = None						,	snake_case_ :       Optional[bool] = None						,	snake_case_ :       bool = False						,	):
							UpperCamelCase_:							Optional[Any]	=						(
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)
							UpperCamelCase_:							str	=						return_dict if return_dict is not None else self.config.use_return_dict

							UpperCamelCase_:							str	=						self.embedder(snake_case_						,	training=snake_case_      )

							UpperCamelCase_:							List[str]	=						self.encoder(
							    snake_case_						,	output_hidden_states=snake_case_						,	return_dict=snake_case_						,	training=snake_case_      )

							UpperCamelCase_:							Optional[int]	=						encoder_outputs[0]
							UpperCamelCase_:							Tuple	=						self.pooler(snake_case_      )

							# Change to NCHW output format have uniformity in the modules
							UpperCamelCase_:							Union[str, Any]	=						tf.transpose(snake_case_						,	perm=(0, 3, 1, 2)      )
							UpperCamelCase_:							Any	=						tf.transpose(snake_case_						,	perm=(0, 3, 1, 2)      )

							# Change the other hidden state outputs to NCHW as well
							if output_hidden_states:
											UpperCamelCase_:							List[Any]	=						tuple([tf.transpose(snake_case_						,	perm=(0, 3, 1, 2)      ) for h in encoder_outputs[1]]      )

							if not return_dict:
											return (last_hidden_state, pooled_output) + encoder_outputs[1:]

							return TFBaseModelOutputWithPoolingAndNoAttention(
							    last_hidden_state=snake_case_						,	pooler_output=snake_case_						,	hidden_states=hidden_states if output_hidden_states else encoder_outputs.hidden_states						,	)




class        _UpperCamelCase				(					_A  ):






			'''simple docstring'''

			__UpperCamelCase      :						Any					      = RegNetConfig
			__UpperCamelCase      :						Union[str, Any]					      = """regnet"""
			__UpperCamelCase      :						str					      = """pixel_values"""

			@property
			def       lowerCAmelCase__	(       self :       Optional[Any]      ):
							return {"pixel_values": tf.TensorSpec(shape=(None, self.config.num_channels, 224, 224)						,	dtype=tf.floataa      )}




lowerCamelCase_						: Tuple         =  r"""
    Parameters:
    This model is a Tensorflow
    [tf.keras.layers.Layer](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Layer) sub-class. Use it as a
    regular Tensorflow Module and refer to the Tensorflow documentation for all matter related to general usage and
    behavior.
        config ([`RegNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~TFPreTrainedModel.from_pretrained`] method to load the model weights.
"""

lowerCamelCase_						: Tuple         =  r"""
    Args:
        pixel_values (`tf.Tensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`ConveNextImageProcessor.__call__`] for details.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""

@add_start_docstrings(
    """The bare RegNet model outputting raw features without any specific head on top."""     ,       _A     ,       )
class        _UpperCamelCase				(					_A  ):






			'''simple docstring'''

			def __init__(       self :       Tuple						,	snake_case_ :       RegNetConfig						,	*snake_case_ :       int						,	**snake_case_ :       Union[str, Any]      ):
							super().__init__(snake_case_						,	*snake_case_						,	**snake_case_      )
							UpperCamelCase_:							int	=						TFRegNetMainLayer(snake_case_						,	name="""regnet"""      )




			@unpack_inputs
			@add_start_docstrings_to_model_forward(snake_case_      )
			@add_code_sample_docstrings(
			    checkpoint=_CHECKPOINT_FOR_DOC						,	output_type=snake_case_						,	config_class=_CONFIG_FOR_DOC						,	modality="""vision"""						,	expected_output=_EXPECTED_OUTPUT_SHAPE						,	)
			def       lowerCAmelCase__	(       self :       Tuple						,	snake_case_ :       tf.Tensor						,	snake_case_ :       Optional[bool] = None						,	snake_case_ :       Optional[bool] = None						,	snake_case_ :       List[str]=False						,	):
							UpperCamelCase_:							Union[str, Any]	=						(
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)
							UpperCamelCase_:							Optional[int]	=						return_dict if return_dict is not None else self.config.use_return_dict

							UpperCamelCase_:							Union[str, Any]	=						self.regnet(
							    pixel_values=snake_case_						,	output_hidden_states=snake_case_						,	return_dict=snake_case_						,	training=snake_case_						,	)
							if not return_dict:
											return (outputs[0],) + outputs[1:]

							return TFBaseModelOutputWithPoolingAndNoAttention(
							    last_hidden_state=outputs.last_hidden_state						,	pooler_output=outputs.pooler_output						,	hidden_states=outputs.hidden_states						,	)




@add_start_docstrings(
    """
    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    """     ,       _A     ,       )
class        _UpperCamelCase				(					_A     ,       _A  ):






			'''simple docstring'''

			def __init__(       self :       Dict						,	snake_case_ :       RegNetConfig						,	*snake_case_ :       Tuple						,	**snake_case_ :       Union[str, Any]      ):
							super().__init__(snake_case_						,	*snake_case_						,	**snake_case_      )
							UpperCamelCase_:							Union[str, Any]	=						config.num_labels
							UpperCamelCase_:							Optional[Any]	=						TFRegNetMainLayer(snake_case_						,	name="""regnet"""      )
							# classification head
							UpperCamelCase_:							Tuple	=						[
							    tf.keras.layers.Flatten(),
							    tf.keras.layers.Dense(config.num_labels						,	name="""classifier.1"""      ) if config.num_labels > 0 else tf.identity,
							]




			@unpack_inputs
			@add_start_docstrings_to_model_forward(snake_case_      )
			@add_code_sample_docstrings(
			    checkpoint=_IMAGE_CLASS_CHECKPOINT						,	output_type=snake_case_						,	config_class=_CONFIG_FOR_DOC						,	expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT						,	)
			def       lowerCAmelCase__	(       self :       List[Any]						,	snake_case_ :       tf.Tensor = None						,	snake_case_ :       tf.Tensor = None						,	snake_case_ :       bool = None						,	snake_case_ :       bool = None						,	snake_case_ :       Union[str, Any]=False						,	):
							UpperCamelCase_:							int	=						(
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)
							UpperCamelCase_:							Optional[int]	=						return_dict if return_dict is not None else self.config.use_return_dict

							UpperCamelCase_:							List[str]	=						self.regnet(
							    snake_case_						,	output_hidden_states=snake_case_						,	return_dict=snake_case_						,	training=snake_case_      )

							UpperCamelCase_:							Optional[Any]	=						outputs.pooler_output if return_dict else outputs[1]

							UpperCamelCase_:							List[Any]	=						self.classifier[0](snake_case_      )
							UpperCamelCase_:							Dict	=						self.classifier[1](snake_case_      )

							UpperCamelCase_:							List[Any]	=						None if labels is None else self.hf_compute_loss(labels=snake_case_						,	logits=snake_case_      )

							if not return_dict:
											UpperCamelCase_:							Tuple	=						(logits,) + outputs[2:]
											return ((loss,) + output) if loss is not None else output

							return TFSequenceClassifierOutput(loss=snake_case_						,	logits=snake_case_						,	hidden_states=outputs.hidden_states      )








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        _UpperCamelCase				(					unittest.TestCase  ):






			'''simple docstring'''

			def       lowerCAmelCase__	(       self :       str      ):
							UpperCamelCase_:							Optional[int]	=						logging.get_logger()

							# the current default level is logging.WARNING
							UpperCamelCase_:							Dict	=						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(snake_case_      )

			def       lowerCAmelCase__	(       self :       Optional[int]      ):
							UpperCamelCase_:							Union[str, Any]	=						logging.get_verbosity()

							UpperCamelCase_:							int	=						logging.get_logger("""transformers.models.bart.tokenization_bart"""      )
							UpperCamelCase_:							Union[str, Any]	=						"""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(snake_case_      ) as cl:
															logger.warning(snake_case_      )
											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(snake_case_      ) as cl:
											logger.warning(snake_case_      )
							self.assertEqual(cl.out						,	""""""      )

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

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

			@mockenv(TRANSFORMERS_VERBOSITY="""error"""      )
			def       lowerCAmelCase__	(       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
							UpperCamelCase_:							List[str]	=						logging.get_logger("""transformers.models.bart.tokenization_bart"""      )

							UpperCamelCase_:							str	=						os.getenv("""TRANSFORMERS_VERBOSITY"""						,	snake_case_      )
							UpperCamelCase_:							Any	=						logging.log_levels[env_level_str]

							UpperCamelCase_:							Dict	=						logging.get_verbosity()
							self.assertEqual(
							    snake_case_						,	snake_case_						,	f'''TRANSFORMERS_VERBOSITY={env_level_str}/{env_level}, but internal verbosity is {current_level}'''						,	)

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

			@mockenv(TRANSFORMERS_VERBOSITY="""super-error"""      )
			def       lowerCAmelCase__	(       self :       List[Any]      ):
							# reset for the env var to take effect, next time some logger call is made
							transformers.utils.logging._reset_library_root_logger()
							UpperCamelCase_:							str	=						logging.logging.getLogger()
							with CaptureLogger(snake_case_      ) 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       lowerCAmelCase__	(       self :       List[Any]      ):
							# testing `logger.warning_advice()`
							transformers.utils.logging._reset_library_root_logger()

							UpperCamelCase_:							List[str]	=						logging.get_logger("""transformers.models.bart.tokenization_bart"""      )
							UpperCamelCase_:							Any	=						"""Testing 1, 2, 3"""

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

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







def        A__					(						)  ->	Union[str, Any]:
				disable_progress_bar()
				assert are_progress_bars_disabled()

				enable_progress_bar()
				assert not are_progress_bars_disabled()






