



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_UpperCamelCase											=		{
    'configuration_bridgetower': [
        'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'BridgeTowerConfig',
        'BridgeTowerTextConfig',
        'BridgeTowerVisionConfig',
    ],
    'processing_bridgetower': ['BridgeTowerProcessor'],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase											=		['BridgeTowerImageProcessor']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase											=		[
       'BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'BridgeTowerForContrastiveLearning',
       'BridgeTowerForImageAndTextRetrieval',
       'BridgeTowerForMaskedLM',
       'BridgeTowerModel',
       'BridgeTowerPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_bridgetower import (
       BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP,
       BridgeTowerConfig,
       BridgeTowerTextConfig,
       BridgeTowerVisionConfig,
   )
   from .processing_bridgetower import BridgeTowerProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_bridgetower import BridgeTowerImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_bridgetower import (
          BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST,
          BridgeTowerForContrastiveLearning,
          BridgeTowerForImageAndTextRetrieval,
          BridgeTowerForMaskedLM,
          BridgeTowerModel,
          BridgeTowerPreTrainedModel,
      )


else:
   import sys

   _UpperCamelCase											=		_LazyModule(__name__, globals()['__file__'], _import_structure)











'''simple docstring'''





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


_UpperCamelCase											=		logging.get_logger(__name__)

_UpperCamelCase											=		{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

_UpperCamelCase											=		{
    'vocab_file': {
        'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt',
        'junnyu/roformer_chinese_base': 'https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt',
        'junnyu/roformer_chinese_char_small': (
            'https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_chinese_char_base': (
            'https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_small_discriminator': (
            'https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_small_generator': (
            'https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt'
        ),
    }
}

_UpperCamelCase											=		{
    'junnyu/roformer_chinese_small': 1536,
    'junnyu/roformer_chinese_base': 1536,
    'junnyu/roformer_chinese_char_small': 512,
    'junnyu/roformer_chinese_char_base': 512,
    'junnyu/roformer_small_discriminator': 128,
    'junnyu/roformer_small_generator': 128,
}


_UpperCamelCase											=		{
    'junnyu/roformer_chinese_small': {'do_lower_case': True},
    'junnyu/roformer_chinese_base': {'do_lower_case': True},
    'junnyu/roformer_chinese_char_small': {'do_lower_case': True},
    'junnyu/roformer_chinese_char_base': {'do_lower_case': True},
    'junnyu/roformer_small_discriminator': {'do_lower_case': True},
    'junnyu/roformer_small_generator': {'do_lower_case': True},
}






class    lowerCamelCase_       (							SCREAMING_SNAKE_CASE_	):
  """simple docstring"""




  a_				   =VOCAB_FILES_NAMES
  a_				   =PRETRAINED_VOCAB_FILES_MAP
  a_				   =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  a_				   =PRETRAINED_INIT_CONFIGURATION
  a_				   =RoFormerTokenizer




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

    __lowerCamelCase			:			List[str]       			=					json.loads(self.backend_tokenizer.normalizer.__getstate__()  )
    if (
        pre_tok_state.get('lowercase'     ,      _a  ) != do_lower_case
        or pre_tok_state.get('strip_accents'     ,      _a  ) != strip_accents
    ):
      __lowerCamelCase			:			Dict       			=					getattr(_a     ,      pre_tok_state.pop('type'  )  )
      __lowerCamelCase			:			Tuple       			=					do_lower_case
      __lowerCamelCase			:			int       			=					strip_accents
      __lowerCamelCase			:			Dict       			=					pre_tok_class(**_a  )

    __lowerCamelCase			:			Any       			=					do_lower_case




  def __getstate__(					self :      Union[str, Any]  )   ->   List[Any]:
    __lowerCamelCase			:			Optional[Any]       			=					self.__dict__.copy()
    __lowerCamelCase			:			Any       			=					BertPreTokenizer()
    return state




  def __setstate__(					self :      Optional[Any]     ,      _a :      Optional[int]  )   ->   Tuple:
    __lowerCamelCase			:			Tuple       			=					d
    __lowerCamelCase			:			Optional[Any]       			=					self.__dict__['_tokenizer'].get_vocab()
    __lowerCamelCase			:			Any       			=					PreTokenizer.custom(JiebaPreTokenizer(_a  )  )




  def 		_lowercase	(					self :      Any     ,      _a :      Union[str, Any]     ,      _a :      str=None  )   ->   Any:
    __lowerCamelCase			:			Optional[Any]       			=					[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 		_lowercase	(					self :      int     ,      _a :      List[int]     ,      _a :      Optional[List[int]] = None  )   ->   List[int]:
    __lowerCamelCase			:			int       			=					[self.sep_token_id]
    __lowerCamelCase			:			int       			=					[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 		_lowercase	(					self :      List[str]     ,      _a :      str     ,      _a :      Optional[str] = None  )   ->   Tuple[str]:
    __lowerCamelCase			:			Optional[int]       			=					self._tokenizer.model.save(_a     ,      name=_a  )
    return tuple(_a  )




  def 		_lowercase	(					self :      int     ,      _a :      Optional[Any]     ,      _a :      Tuple=None     ,      _a :      List[str]=None     ,      _a :      Optional[int]=False     ,      **_a :      Dict     ,      )   ->   Dict:
    __lowerCamelCase			:			Dict       			=					BertPreTokenizer()
    return super().save_pretrained(_a     ,      _a     ,      _a     ,      _a     ,      **_a  )






