import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


a  :      Dict            =    logging.get_logger(__name__)

a  :      str            =    {"""vocab_file""": """vocab.txt"""}

a  :      Any            =    {
    """vocab_file""": {
        """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt""",
        """YituTech/conv-bert-medium-small""": (
            """https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"""
        ),
        """YituTech/conv-bert-small""": """https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt""",
    }
}

a  :      Optional[Any]            =    {
    """YituTech/conv-bert-base""": 5_1_2,
    """YituTech/conv-bert-medium-small""": 5_1_2,
    """YituTech/conv-bert-small""": 5_1_2,
}


a  :      Optional[int]            =    {
    """YituTech/conv-bert-base""": {"""do_lower_case""": True},
    """YituTech/conv-bert-medium-small""": {"""do_lower_case""": True},
    """YituTech/conv-bert-small""": {"""do_lower_case""": True},
}

class 					_lowercase    (     A__			):






    '''simple docstring'''
    SCREAMING_SNAKE_CASE:				List[Any]          =    VOCAB_FILES_NAMES
    SCREAMING_SNAKE_CASE:				Optional[Any]          =    PRETRAINED_VOCAB_FILES_MAP
    SCREAMING_SNAKE_CASE:				Dict          =    PRETRAINED_INIT_CONFIGURATION
    SCREAMING_SNAKE_CASE:				List[str]          =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    SCREAMING_SNAKE_CASE:				Tuple          =    ConvBertTokenizer




    def __init__(    self       ,						lowerCamelCase__=None       ,						lowerCamelCase__=None       ,						lowerCamelCase__=True       ,						lowerCamelCase__="[UNK]"       ,						lowerCamelCase__="[SEP]"       ,						lowerCamelCase__="[PAD]"       ,						lowerCamelCase__="[CLS]"       ,						lowerCamelCase__="[MASK]"       ,						lowerCamelCase__=True       ,						lowerCamelCase__=None       ,						**lowerCamelCase__       ,						):
       super().__init__(
           UpperCamelCase_       ,						tokenizer_file=UpperCamelCase_       ,						do_lower_case=UpperCamelCase_       ,						unk_token=UpperCamelCase_       ,						sep_token=UpperCamelCase_       ,						pad_token=UpperCamelCase_       ,						cls_token=UpperCamelCase_       ,						mask_token=UpperCamelCase_       ,						tokenize_chinese_chars=UpperCamelCase_       ,						strip_accents=UpperCamelCase_       ,						**UpperCamelCase_       ,						)

       lowerCAmelCase_:							List[Any]       =	json.loads(self.backend_tokenizer.normalizer.__getstate__() )
       if (
           normalizer_state.get("lowercase"       ,						UpperCamelCase_ ) != do_lower_case
           or normalizer_state.get("strip_accents"       ,						UpperCamelCase_ ) != strip_accents
           or normalizer_state.get("handle_chinese_chars"       ,						UpperCamelCase_ ) != tokenize_chinese_chars
       ):
          lowerCAmelCase_:							Optional[int]       =	getattr(UpperCamelCase_       ,						normalizer_state.pop("type" ) )
          lowerCAmelCase_:							int       =	do_lower_case
          lowerCAmelCase_:							List[str]       =	strip_accents
          lowerCAmelCase_:							Tuple       =	tokenize_chinese_chars
          lowerCAmelCase_:							Tuple       =	normalizer_class(**UpperCamelCase_ )

       lowerCAmelCase_:							Tuple       =	do_lower_case




    def      _a    (    self       ,						lowerCamelCase__       ,						lowerCamelCase__=None ):
       lowerCAmelCase_:							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      _a    (    self       ,						lowerCamelCase__       ,						lowerCamelCase__ = None ):
       lowerCAmelCase_:							str       =	[self.sep_token_id]
       lowerCAmelCase_:							List[Any]       =	[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      _a    (    self       ,						lowerCamelCase__       ,						lowerCamelCase__ = None ):
       lowerCAmelCase_:							int       =	self._tokenizer.model.save(UpperCamelCase_       ,						name=UpperCamelCase_ )
       return tuple(UpperCamelCase_ )



'''simple docstring'''
import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class   lowercase      (				A__   ):

		"""simple docstring"""

		_a       					=							['image_processor', 'tokenizer']
		_a       					=							'ChineseCLIPImageProcessor'
		_a       					=							('BertTokenizer', 'BertTokenizerFast')




		def __init__(						self       ,  UpperCamelCase_=None       ,  UpperCamelCase_=None       ,  **UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :List[Any]				   =					None
							if "feature_extractor" in kwargs:
												warnings.warn(
												    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
												    ''' instead.'''       ,  UpperCamelCase_       ,  )
												UpperCamelCase__  :List[Any]				   =					kwargs.pop('''feature_extractor'''				)

							UpperCamelCase__  :List[str]				   =					image_processor if image_processor is not None else feature_extractor
							if image_processor is None:
												raise ValueError('''You need to specify an `image_processor`.'''				)
							if tokenizer is None:
												raise ValueError('''You need to specify a `tokenizer`.'''				)

							super().__init__(UpperCamelCase_       ,  UpperCamelCase_				)
							UpperCamelCase__  :Any				   =					self.image_processor




		def __call__(						self       ,  UpperCamelCase_=None       ,  UpperCamelCase_=None       ,  UpperCamelCase_=None       ,  **UpperCamelCase_				):

							'''simple docstring'''


							if text is None and images is None:
												raise ValueError('''You have to specify either text or images. Both cannot be none.'''				)

							if text is not None:
												UpperCamelCase__  :Tuple				   =					self.tokenizer(UpperCamelCase_       ,  return_tensors=UpperCamelCase_       ,  **UpperCamelCase_				)

							if images is not None:
												UpperCamelCase__  :Any				   =					self.image_processor(UpperCamelCase_       ,  return_tensors=UpperCamelCase_       ,  **UpperCamelCase_				)

							if text is not None and images is not None:
												UpperCamelCase__  :Optional[int]				   =					image_features.pixel_values
												return encoding
							elif text is not None:
												return encoding
							else:
												return BatchEncoding(data=dict(**UpperCamelCase_				)       ,  tensor_type=UpperCamelCase_				)




		def        lowerCAmelCase__							(						self       ,  *UpperCamelCase_       ,  **UpperCamelCase_				):

							'''simple docstring'''


							return self.tokenizer.batch_decode(*UpperCamelCase_       ,  **UpperCamelCase_				)




		def        lowerCAmelCase__							(						self       ,  *UpperCamelCase_       ,  **UpperCamelCase_				):

							'''simple docstring'''


							return self.tokenizer.decode(*UpperCamelCase_       ,  **UpperCamelCase_				)




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :int				   =					self.tokenizer.model_input_names
							UpperCamelCase__  :Any				   =					self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							warnings.warn(
							    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''       ,  UpperCamelCase_       ,  )
							return self.image_processor_class