






"""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


_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						threading.Lock()
_SCREAMING_SNAKE_CASE					:				Optional[logging.Handler]					    =						None

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

_SCREAMING_SNAKE_CASE					:				Tuple					    =						logging.WARNING

_SCREAMING_SNAKE_CASE					:				str					    =						True







def      lowerCamelCase__       (							)      ->				Tuple:
  lowerCamelCase_         =						os.getenv('TRANSFORMERS_VERBOSITY'		,				_lowerCamelCase )
  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__       (							)      ->				str:
  return __name__.split('.' )[0]







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







def      lowerCamelCase__       (							)      ->				None:
  global _default_handler

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

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







def      lowerCamelCase__       (							)      ->				None:
  global _default_handler

  with _lock:
    if not _default_handler:
      return

    lowerCamelCase_         =						_get_library_root_logger()
    library_root_logger.removeHandler(_default_handler )
    library_root_logger.setLevel(logging.NOTSET )
    lowerCamelCase_         =						None







def      lowerCamelCase__       (							)      ->				Optional[Any]:
  return log_levels







def      lowerCamelCase__       (							_lowerCamelCase       :		Optional[str] = None )      ->				logging.Logger:

  if name is None:
    lowerCamelCase_         =						_get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(_lowerCamelCase )







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







def      lowerCamelCase__       (							_lowerCamelCase       :		int )      ->				None:
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				int:
  return set_verbosity(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				Tuple:
  return set_verbosity(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				str:
  return set_verbosity(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				Tuple:
  return set_verbosity(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				None:
  _configure_library_root_logger()

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







def      lowerCamelCase__       (							)      ->				None:
  _configure_library_root_logger()

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







def      lowerCamelCase__       (							_lowerCamelCase       :		logging.Handler )      ->				None:
  _configure_library_root_logger()

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







def      lowerCamelCase__       (							_lowerCamelCase       :		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(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				None:
  _configure_library_root_logger()
  lowerCamelCase_         =						False







def      lowerCamelCase__       (							)      ->				None:
  _configure_library_root_logger()
  lowerCamelCase_         =						True







def      lowerCamelCase__       (							)      ->				None:
  lowerCamelCase_         =						_get_library_root_logger().handlers

  for handler in handlers:
    lowerCamelCase_         =						logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s' )
    handler.setFormatter(_lowerCamelCase )







def      lowerCamelCase__       (							)      ->				None:
  lowerCamelCase_         =						_get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(_lowerCamelCase )







def      lowerCamelCase__       (							self       :		Any		,				*_lowerCamelCase       :		Optional[Any]		,				**_lowerCamelCase       :		str )      ->				Optional[int]:
  lowerCamelCase_         =						os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS'		,				_lowerCamelCase )
  if no_advisory_warnings:
    return
  self.warning(*_lowerCamelCase		,				**_lowerCamelCase )


_SCREAMING_SNAKE_CASE					:				Optional[int]					    =						warning_advice







@functools.lru_cache(_lowerCamelCase )
def      lowerCamelCase__       (							self       :		Union[str, Any]		,				*_lowerCamelCase       :		List[str]		,				**_lowerCamelCase       :		Dict )      ->				int:
  self.warning(*_lowerCamelCase		,				**_lowerCamelCase )


_SCREAMING_SNAKE_CASE					:				Any					    =						warning_once






class      a						:






    def __init__(       self     :							Union[str, Any]       ,						*__SCREAMING_SNAKE_CASE     :							Optional[Any]       ,						**__SCREAMING_SNAKE_CASE     :							Tuple					)     ->		Any:  # pylint: disable=unused-argument
      lowerCamelCase_         =						args[0] if args else None






    def __iter__(       self     :							List[Any]					)     ->		List[Any]:
      return iter(self._iterator					)






    def __getattr__(       self     :							List[Any]       ,						__SCREAMING_SNAKE_CASE     :							str					)     ->		List[str]:

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

      return empty_fn






    def __enter__(       self     :							Optional[int]					)     ->		Optional[int]:
      return self






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






class      a						:






    def __call__(       self     :							Optional[int]       ,						*__SCREAMING_SNAKE_CASE     :							int       ,						**__SCREAMING_SNAKE_CASE     :							Optional[int]					)     ->		List[Any]:
      if _tqdm_active:
        return tqdm_lib.tqdm(*__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE					)
      else:
        return EmptyTqdm(*__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE					)






    def    UpperCamelCase       (       self     :							List[Any]       ,						*__SCREAMING_SNAKE_CASE     :							Optional[Any]       ,						**__SCREAMING_SNAKE_CASE     :							List[Any]					)     ->		str:
      lowerCamelCase_         =						None
      if _tqdm_active:
        return tqdm_lib.tqdm.set_lock(*__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE					)






    def    UpperCamelCase       (       self     :							int					)     ->		Optional[Any]:
      if _tqdm_active:
        return tqdm_lib.tqdm.get_lock()
_SCREAMING_SNAKE_CASE					:				Optional[Any]					    =						_tqdm_cls()







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







def      lowerCamelCase__       (							)      ->				List[str]:
  global _tqdm_active
  lowerCamelCase_         =						True
  hf_hub_utils.enable_progress_bars()







def      lowerCamelCase__       (							)      ->				Optional[Any]:
  global _tqdm_active
  lowerCamelCase_         =						False
  hf_hub_utils.disable_progress_bars()












"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_SCREAMING_SNAKE_CASE					:				Union[str, Any]					    =						{
    '''vocab_file''': {
        '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt''',
    },
    '''tokenizer_file''': {
        '''unc-nlp/lxmert-base-uncased''': (
            '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

_SCREAMING_SNAKE_CASE					:				Any					    =						{
    '''unc-nlp/lxmert-base-uncased''': 512,
}

_SCREAMING_SNAKE_CASE					:				int					    =						{
    '''unc-nlp/lxmert-base-uncased''': {'''do_lower_case''': True},
}






class      a						(					__snake_case		):
    SCREAMING_SNAKE_CASE						:     int						= VOCAB_FILES_NAMES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= PRETRAINED_VOCAB_FILES_MAP
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_INIT_CONFIGURATION
    SCREAMING_SNAKE_CASE						:     Any						= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    SCREAMING_SNAKE_CASE						:     Optional[Any]						= LxmertTokenizer






    def __init__(       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							Optional[Any]=None       ,						__SCREAMING_SNAKE_CASE     :							str=True       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[UNK]"       ,						__SCREAMING_SNAKE_CASE     :							int="[SEP]"       ,						__SCREAMING_SNAKE_CASE     :							int="[PAD]"       ,						__SCREAMING_SNAKE_CASE     :							List[Any]="[CLS]"       ,						__SCREAMING_SNAKE_CASE     :							Any="[MASK]"       ,						__SCREAMING_SNAKE_CASE     :							List[str]=True       ,						__SCREAMING_SNAKE_CASE     :							List[str]=None       ,						**__SCREAMING_SNAKE_CASE     :							Any       ,						)     ->		Any:
      super().__init__(
          __SCREAMING_SNAKE_CASE       ,						tokenizer_file=__SCREAMING_SNAKE_CASE       ,						do_lower_case=__SCREAMING_SNAKE_CASE       ,						unk_token=__SCREAMING_SNAKE_CASE       ,						sep_token=__SCREAMING_SNAKE_CASE       ,						pad_token=__SCREAMING_SNAKE_CASE       ,						cls_token=__SCREAMING_SNAKE_CASE       ,						mask_token=__SCREAMING_SNAKE_CASE       ,						tokenize_chinese_chars=__SCREAMING_SNAKE_CASE       ,						strip_accents=__SCREAMING_SNAKE_CASE       ,						**__SCREAMING_SNAKE_CASE       ,						)

      lowerCamelCase_         =						json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
      if (
          normalizer_state.get('lowercase'       ,						__SCREAMING_SNAKE_CASE					) != do_lower_case
          or normalizer_state.get('strip_accents'       ,						__SCREAMING_SNAKE_CASE					) != strip_accents
          or normalizer_state.get('handle_chinese_chars'       ,						__SCREAMING_SNAKE_CASE					) != tokenize_chinese_chars
      ):
        lowerCamelCase_         =						getattr(__SCREAMING_SNAKE_CASE       ,						normalizer_state.pop('type'					)					)
        lowerCamelCase_         =						do_lower_case
        lowerCamelCase_         =						strip_accents
        lowerCamelCase_         =						tokenize_chinese_chars
        lowerCamelCase_         =						normalizer_class(**__SCREAMING_SNAKE_CASE					)

      lowerCamelCase_         =						do_lower_case






    def    UpperCamelCase       (       self     :							Tuple       ,						__SCREAMING_SNAKE_CASE     :							Union[str, Any]       ,						__SCREAMING_SNAKE_CASE     :							Tuple=None					)     ->		Dict:
      lowerCamelCase_         =						[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
        output += token_ids_a + [self.sep_token_id]

      return output






    def    UpperCamelCase       (       self     :							str       ,						__SCREAMING_SNAKE_CASE     :							List[int]       ,						__SCREAMING_SNAKE_CASE     :							Optional[List[int]] = None					)     ->		List[int]:
      lowerCamelCase_         =						[self.sep_token_id]
      lowerCamelCase_         =						[self.cls_token_id]
      if token_ids_a is None:
        return len(cls + token_ids_a + sep					) * [0]
      return len(cls + token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1]






    def    UpperCamelCase       (       self     :							List[str]       ,						__SCREAMING_SNAKE_CASE     :							str       ,						__SCREAMING_SNAKE_CASE     :							Optional[str] = None					)     ->		Tuple[str]:
      lowerCamelCase_         =						self._tokenizer.model.save(__SCREAMING_SNAKE_CASE       ,						name=__SCREAMING_SNAKE_CASE					)
      return tuple(__SCREAMING_SNAKE_CASE					)




