






"""simple docstring"""

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


lowercase    			=       threading.Lock()
lowercase    			=       None

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

lowercase    			=       logging.WARNING

lowercase    			=       True
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						__magic_name__            =     os.getenv("TRANSFORMERS_VERBOSITY" ,						a_   )
						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	(  ):

						'''simple docstring'''






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

						'''simple docstring'''






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

						'''simple docstring'''






						global _default_handler

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

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

						'''simple docstring'''






						global _default_handler

						with _lock:
												if not _default_handler:
																		return

												__magic_name__            =     _get_library_root_logger()
												library_root_logger.removeHandler(_default_handler   )
												library_root_logger.setLevel(logging.NOTSET   )
												__magic_name__            =     None
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						return log_levels
def _lowerCAmelCase	(  __lowerCamelCase:Optional[str] = None   ):

						'''simple docstring'''






						if name is None:
												__magic_name__            =     _get_library_name()

						_configure_library_root_logger()
						return logging.getLogger(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






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

						'''simple docstring'''






						_configure_library_root_logger()
						_get_library_root_logger().setLevel(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						return set_verbosity(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						return set_verbosity(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						return set_verbosity(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						return set_verbosity(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						_configure_library_root_logger()

						assert _default_handler is not None
						_get_library_root_logger().removeHandler(_default_handler   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						_configure_library_root_logger()

						assert _default_handler is not None
						_get_library_root_logger().addHandler(_default_handler   )
def _lowerCAmelCase	(  __lowerCamelCase:logging.Handler   ):

						'''simple docstring'''






						_configure_library_root_logger()

						assert handler is not None
						_get_library_root_logger().addHandler(a_   )
def _lowerCAmelCase	(  __lowerCamelCase:logging.Handler   ):

						'''simple docstring'''






						_configure_library_root_logger()

						assert handler is not None and handler not in _get_library_root_logger().handlers
						_get_library_root_logger().removeHandler(a_   )
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						_configure_library_root_logger()
						__magic_name__            =     False
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						_configure_library_root_logger()
						__magic_name__            =     True
def _lowerCAmelCase	(  ):

						'''simple docstring'''






						__magic_name__            =     _get_library_root_logger().handlers

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

						'''simple docstring'''






						__magic_name__            =     _get_library_root_logger().handlers

						for handler in handlers:
												handler.setFormatter(a_   )
def _lowerCAmelCase	(  self:Optional[int] ,						*__lowerCamelCase:str ,						**__lowerCamelCase:List[Any]   ):

						'''simple docstring'''






						__magic_name__            =     os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS" ,						a_   )
						if no_advisory_warnings:
												return
						self.warning(*a_ ,						**a_   )


lowercase    			=       warning_advice
@functools.lru_cache(a_   )
def _lowerCAmelCase	(  self:int ,						*__lowerCamelCase:Union[str, Any] ,						**__lowerCamelCase:Optional[Any]   ):

						'''simple docstring'''






						self.warning(*a_ ,						**a_   )


lowercase    			=       warning_once

class 						A_							:







				def __init__(							self							:						Any						,    *__lowerCamelCase							:						str						,    **__lowerCamelCase							:						List[str]	)				->					Optional[int]:  # pylint: disable=unused-argument
										__magic_name__            =     args[0] if args else None







				def __iter__(							self							:						Optional[int]	)				->					List[str]:
										return iter(self._iterator	)







				def __getattr__(							self							:						Optional[int]						,    __lowerCamelCase							:						Dict	)				->					List[Any]:

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

										return empty_fn







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







				def __exit__(							self							:						Optional[int]						,    __lowerCamelCase							:						Any						,    __lowerCamelCase							:						List[str]						,    __lowerCamelCase							:						Optional[Any]	)				->					int:
										return





class 						A_							:







				def __call__(							self							:						Optional[int]						,    *__lowerCamelCase							:						Dict						,    **__lowerCamelCase							:						Optional[Any]	)				->					str:
										if _tqdm_active:
																return tqdm_lib.tqdm(*__snake_case						,    **__snake_case	)
										else:
																return EmptyTqdm(*__snake_case						,    **__snake_case	)







				def     _snake_case					(							self							:						int						,    *__lowerCamelCase							:						Union[str, Any]						,    **__lowerCamelCase							:						Union[str, Any]	)				->					Any:
										__magic_name__            =     None
										if _tqdm_active:
																return tqdm_lib.tqdm.set_lock(*__snake_case						,    **__snake_case	)







				def     _snake_case					(							self							:						Tuple	)				->					Union[str, Any]:
										if _tqdm_active:
																return tqdm_lib.tqdm.get_lock()





lowercase    			=       _tqdm_cls()
def _lowerCAmelCase	(  ):

						'''simple docstring'''






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

						'''simple docstring'''






						global _tqdm_active
						__magic_name__            =     True
						hf_hub_utils.enable_progress_bars()


def _lowerCAmelCase	(  ):

						'''simple docstring'''






						global _tqdm_active
						__magic_name__            =     False
						hf_hub_utils.disable_progress_bars()











"""simple docstring"""

from copy import deepcopy

class 						A_							:







				def __init__(							self							:						List[str]						,    __lowerCamelCase							:						list[int] | None = None						,    __lowerCamelCase							:						int | None = None	)				->					None:

										if arr is None and size is not None:
																__magic_name__            =     size
																__magic_name__            =     [0] * size
										elif arr is not None:
																self.init(__lowerCamelCase	)
										else:
																raise ValueError("Either arr or size must be specified"	)







				def     _snake_case					(							self							:						Optional[int]						,    __lowerCamelCase							:						list[int]	)				->					None:
										__magic_name__            =     len(__lowerCamelCase	)
										__magic_name__            =     deepcopy(__lowerCamelCase	)
										for i in range(1						,    self.size	):
																__magic_name__            =     self.next_(__lowerCamelCase	)
																if j < self.size:
																						self.tree[j] += self.tree[i]







				def     _snake_case					(							self							:						Any	)				->					list[int]:
										__magic_name__            =     self.tree[:]
										for i in range(self.size - 1						,    0						,    -1	):
																__magic_name__            =     self.next_(__lowerCamelCase	)
																if j < self.size:
																						arr[j] -= arr[i]
										return arr







				@staticmethod
				def     _snake_case					(							__lowerCamelCase							:						int	)				->					int:
										return index + (index & (-index))







				@staticmethod
				def     _snake_case					(							__lowerCamelCase							:						int	)				->					int:
										return index - (index & (-index))







				def     _snake_case					(							self							:						Union[str, Any]						,    __lowerCamelCase							:						int						,    __lowerCamelCase							:						int	)				->					None:
										if index == 0:
																self.tree[0] += value
																return
										while index < self.size:
																self.tree[index] += value
																__magic_name__            =     self.next_(__lowerCamelCase	)







				def     _snake_case					(							self							:						Any						,    __lowerCamelCase							:						int						,    __lowerCamelCase							:						int	)				->					None:
										self.add(__lowerCamelCase						,    value - self.get(__lowerCamelCase	)	)







				def     _snake_case					(							self							:						List[Any]						,    __lowerCamelCase							:						int	)				->					int:
										if right == 0:
																return 0
										__magic_name__            =     self.tree[0]
										right -= 1  # make right inclusive
										while right > 0:
																result += self.tree[right]
																__magic_name__            =     self.prev(__lowerCamelCase	)
										return result







				def     _snake_case					(							self							:						Any						,    __lowerCamelCase							:						int						,    __lowerCamelCase							:						int	)				->					int:
										return self.prefix(__lowerCamelCase	) - self.prefix(__lowerCamelCase	)







				def     _snake_case					(							self							:						Tuple						,    __lowerCamelCase							:						int	)				->					int:
										return self.query(__lowerCamelCase						,    index + 1	)







				def     _snake_case					(							self							:						Tuple						,    __lowerCamelCase							:						int	)				->					int:
										value -= self.tree[0]
										if value < 0:
																return -1

										__magic_name__            =     1  # Largest power of 2 <= size
										while j * 2 < self.size:
																j *= 2

										__magic_name__            =     0

										while j > 0:
																if i + j < self.size and self.tree[i + j] <= value:
																						value -= self.tree[i + j]
																						i += j
																j //= 2
										return i


if __name__ == "__main__":
			import doctest

			doctest.testmod()



