




from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_clip import CLIPTokenizer


__magic_name__     :     Any  							=					logging.get_logger(__name__)

__magic_name__     :     int  							=					{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

__magic_name__     :     int  							=					{
    """vocab_file""": {
        """openai/clip-vit-base-patch32""": """https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/vocab.json""",
    },
    """merges_file""": {
        """openai/clip-vit-base-patch32""": """https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/merges.txt""",
    },
    """tokenizer_file""": {
        """openai/clip-vit-base-patch32""": (
            """https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/tokenizer.json"""
        ),
    },
}

__magic_name__     :     str  							=					{
    """openai/clip-vit-base-patch32""": 77,
}





class 						SCREAMING_SNAKE_CASE__		(_a ):
     lowercase_   :			List[Any]   =   VOCAB_FILES_NAMES
     lowercase_   :			Optional[int]   =   PRETRAINED_VOCAB_FILES_MAP
     lowercase_   :			List[Any]   =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     lowercase_   :			Union[str, Any]   =   ["input_ids", "attention_mask"]
     lowercase_   :			Any   =   CLIPTokenizer
     def __init__(	self  :		Optional[Any]					,	__lowerCamelCase  :		List[Any]=None					,	__lowerCamelCase  :		Optional[Any]=None					,	__lowerCamelCase  :		Union[str, Any]=None					,	__lowerCamelCase  :		Union[str, Any]="<|endoftext|>"					,	__lowerCamelCase  :		Optional[int]="<|startoftext|>"					,	__lowerCamelCase  :		List[Any]="<|endoftext|>"					,	__lowerCamelCase  :		Optional[Any]="<|endoftext|>"					,	**__lowerCamelCase  :		Optional[Any]					,	):



       """simple docstring"""
       super().__init__(
           __lowerCamelCase					,	__lowerCamelCase					,	tokenizer_file=__lowerCamelCase					,	unk_token=__lowerCamelCase					,	bos_token=__lowerCamelCase					,	eos_token=__lowerCamelCase					,	pad_token=__lowerCamelCase					,	**__lowerCamelCase					,	)

       if not isinstance(self.backend_tokenizer.pre_tokenizer					,	pre_tokenizers.Sequence	):
         raise ValueError(
             '''The `backend_tokenizer` provided does not match the expected format. The CLIP tokenizer has been'''
             ''' heavily modified from transformers version 4.17.0. You need to convert the tokenizer you are using'''
             ''' to be compatible with this version.The easiest way to do so is'''
             ''' `CLIPTokenizerFast.from_pretrained("path_to_local_folder_or_hub_repo, from_slow=True)`. If you want'''
             ''' to use your existing tokenizer, you will have to revert to a version prior to 4.17.0 of'''
             ''' transformers.'''	)

       self._wrap_decode_method_backend_tokenizer()
     def 					A__			(	self  :		Tuple	):



       """simple docstring"""
       lowerCAmelCase__								=			self.backend_tokenizer.decode

       def new_decode_method(*__lowerCamelCase  :		int					,	**__lowerCamelCase  :		int	):
         lowerCAmelCase__								=			orig_decode_method(*__lowerCamelCase					,	**__lowerCamelCase	)
         lowerCAmelCase__								=			text.replace(self.backend_tokenizer.model.end_of_word_suffix					,	''' '''	).strip()
         return text

       lowerCAmelCase__								=			new_decode_method
     def 					A__			(	self  :		List[Any]					,	__lowerCamelCase  :		List[int]					,	__lowerCamelCase  :		Optional[List[int]] = None	):



       """simple docstring"""
       lowerCAmelCase__								=			[self.bos_token_id]
       lowerCAmelCase__								=			[self.eos_token_id]

       if token_ids_a is None:
         return bos_token + token_ids_a + eos_token
       return bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token
     def 					A__			(	self  :		Tuple					,	__lowerCamelCase  :		List[int]					,	__lowerCamelCase  :		Optional[List[int]] = None	):



       """simple docstring"""
       lowerCAmelCase__								=			[self.bos_token_id]
       lowerCAmelCase__								=			[self.eos_token_id]

       if token_ids_a is None:
         return len(bos_token + token_ids_a + eos_token	) * [0]
       return len(bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token	) * [0]



     def 					A__			(	self  :		Optional[int]					,	__lowerCamelCase  :		str					,	__lowerCamelCase  :		Optional[str] = None	):



       """simple docstring"""
       lowerCAmelCase__								=			self._tokenizer.model.save(__lowerCamelCase					,	name=__lowerCamelCase	)
       return tuple(__lowerCamelCase	)







def 		a_       (   __lowerCAmelCase      ,   __lowerCAmelCase							):
  lowerCAmelCase__								=			0
  for ele in arr:
    total_sum += product_sum(__lowerCAmelCase      ,   depth + 1							) if isinstance(__lowerCAmelCase      ,   __lowerCAmelCase							) else ele
  return total_sum * depth
def 		a_       (   __lowerCAmelCase							):
  return product_sum(__lowerCAmelCase      ,   1							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()

