

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


A_       : Tuple         =			threading.Lock()
A_       : Optional[logging.Handler]         =			None

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

A_       : List[str]         =			logging.WARNING

A_       : Tuple         =			True

def 						UpperCamelCase					()     ->      List[str]:
	A__							:    Dict        =		os.getenv("""TRANSFORMERS_VERBOSITY"""    ,      lowercase_					)
	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 						UpperCamelCase					()     ->      str:
	return __name__.split("""."""					)[0]

def 						UpperCamelCase					()     ->      logging.Logger:
	return logging.getLogger(_get_library_name()					)

def 						UpperCamelCase					()     ->      None:
	global _default_handler

	with _lock:
		if _default_handler:
			# This library has already configured the library root logger.
			return
		A__							:    Tuple        =		logging.StreamHandler()  # Set sys.stderr as stream.
		A__							:    List[Any]        =		sys.stderr.flush

		# Apply our default configuration to the library root logger.
		A__							:    List[Any]        =		_get_library_root_logger()
		library_root_logger.addHandler(_default_handler					)
		library_root_logger.setLevel(_get_default_logging_level()					)
		A__							:    Union[str, Any]        =		False

def 						UpperCamelCase					()     ->      None:
	global _default_handler

	with _lock:
		if not _default_handler:
			return

		A__							:    int        =		_get_library_root_logger()
		library_root_logger.removeHandler(_default_handler					)
		library_root_logger.setLevel(logging.NOTSET					)
		A__							:    Optional[int]        =		None

def 						UpperCamelCase					()     ->      Tuple:
	return log_levels

def 						UpperCamelCase					(lowercase_: Optional[str] = None					)     ->      logging.Logger:

	if name is None:
		A__							:    Dict        =		_get_library_name()

	_configure_library_root_logger()
	return logging.getLogger(lowercase_					)

def 						UpperCamelCase					()     ->      int:
	_configure_library_root_logger()
	return _get_library_root_logger().getEffectiveLevel()

def 						UpperCamelCase					(lowercase_: int					)     ->      None:
	_configure_library_root_logger()
	_get_library_root_logger().setLevel(lowercase_					)

def 						UpperCamelCase					()     ->      Union[str, Any]:
	return set_verbosity(lowercase_					)

def 						UpperCamelCase					()     ->      Union[str, Any]:
	return set_verbosity(lowercase_					)

def 						UpperCamelCase					()     ->      List[Any]:
	return set_verbosity(lowercase_					)

def 						UpperCamelCase					()     ->      Union[str, Any]:
	return set_verbosity(lowercase_					)

def 						UpperCamelCase					()     ->      None:
	_configure_library_root_logger()

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

def 						UpperCamelCase					()     ->      None:
	_configure_library_root_logger()

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

def 						UpperCamelCase					(lowercase_: logging.Handler					)     ->      None:
	_configure_library_root_logger()

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

def 						UpperCamelCase					(lowercase_: logging.Handler					)     ->      None:
	_configure_library_root_logger()

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

def 						UpperCamelCase					()     ->      None:
	_configure_library_root_logger()
	A__							:    Any        =		False

def 						UpperCamelCase					()     ->      None:
	_configure_library_root_logger()
	A__							:    List[Any]        =		True

def 						UpperCamelCase					()     ->      None:
	A__							:    List[Any]        =		_get_library_root_logger().handlers

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

def 						UpperCamelCase					()     ->      None:
	A__							:    Optional[Any]        =		_get_library_root_logger().handlers

	for handler in handlers:
		handler.setFormatter(lowercase_					)

def 						UpperCamelCase					(self: List[str]    ,      *lowercase_: Optional[int]    ,      **lowercase_: Dict					)     ->      str:
	A__							:    Tuple        =		os.getenv("""TRANSFORMERS_NO_ADVISORY_WARNINGS"""    ,      lowercase_					)
	if no_advisory_warnings:
		return
	self.warning(*lowercase_    ,      **lowercase_					)


A_       : Optional[int]         =			warning_advice

@functools.lru_cache(lowercase_					)
def 						UpperCamelCase					(self: Tuple    ,      *lowercase_: int    ,      **lowercase_: Optional[Any]					)     ->      List[Any]:
	self.warning(*lowercase_    ,      **lowercase_					)


A_       : List[str]         =			warning_once



class     _a						:


					'''simple docstring'''






					def __init__( self    ,       *A__    ,       **A__			):  # pylint: disable=unused-argument
						A__							:    List[Any]        =		args[0] if args else None






					def __iter__( self			):
						return iter(self._iterator			)






					def __getattr__( self    ,       A__			):

						def empty_fn(*A__    ,       **A__			):  # pylint: disable=unused-argument
							return

						return empty_fn






					def __enter__( self			):
						return self






					def __exit__( self    ,       A__    ,       A__    ,       A__			):
						return



class     _a						:


					'''simple docstring'''






					def __call__( self    ,       *A__    ,       **A__			):
						if _tqdm_active:
							return tqdm_lib.tqdm(*A__    ,       **A__			)
						else:
							return EmptyTqdm(*A__    ,       **A__			)






					def   __A			( self    ,       *A__    ,       **A__			):
						A__							:    List[Any]        =		None
						if _tqdm_active:
							return tqdm_lib.tqdm.set_lock(*A__    ,       **A__			)






					def   __A			( self			):
						if _tqdm_active:
							return tqdm_lib.tqdm.get_lock()



A_       : Dict         =			_tqdm_cls()

def 						UpperCamelCase					()     ->      bool:
	global _tqdm_active
	return bool(_tqdm_active					)

def 						UpperCamelCase					()     ->      Optional[int]:
	global _tqdm_active
	A__							:    List[str]        =		True
	hf_hub_utils.enable_progress_bars()


def 						UpperCamelCase					()     ->      List[str]:
	global _tqdm_active
	A__							:    Dict        =		False
	hf_hub_utils.disable_progress_bars()






from ...configuration_utils import PretrainedConfig
from ...utils import logging


A_       : int         =			logging.get_logger(__name__)

A_       : Optional[Any]         =			{
    'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json',
}



class     _a						(__magic_name__				):


					'''simple docstring'''






					UpperCAmelCase__:   List[Any]  							=       '''mgp-str'''






					def __init__( self    ,       A__=[32, 128]    ,       A__=4    ,       A__=3    ,       A__=27    ,       A__=38    ,       A__=5_0257    ,       A__=3_0522    ,       A__=768    ,       A__=12    ,       A__=12    ,       A__=4.0    ,       A__=True    ,       A__=False    ,       A__=1e-5    ,       A__=0.0    ,       A__=0.0    ,       A__=0.0    ,       A__=False    ,       A__=0.0_2    ,       **A__    ,       ):
						super().__init__(**A__			)

						A__							:    Dict        =		image_size
						A__							:    int        =		patch_size
						A__							:    Dict        =		num_channels
						A__							:    List[Any]        =		max_token_length
						A__							:    str        =		num_character_labels
						A__							:    Tuple        =		num_bpe_labels
						A__							:    Optional[Any]        =		num_wordpiece_labels
						A__							:    Optional[int]        =		hidden_size
						A__							:    Tuple        =		num_hidden_layers
						A__							:    Any        =		num_attention_heads
						A__							:    List[Any]        =		mlp_ratio
						A__							:    Tuple        =		distilled
						A__							:    Union[str, Any]        =		layer_norm_eps
						A__							:    Tuple        =		drop_rate
						A__							:    List[str]        =		qkv_bias
						A__							:    Optional[Any]        =		attn_drop_rate
						A__							:    Union[str, Any]        =		drop_path_rate
						A__							:    Optional[Any]        =		output_aa_attentions
						A__							:    Optional[int]        =		initializer_range



