
'''simple docstring'''





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


a		:  Union[str, Any]   			=			logging.get_logger(__name__)

a		:  str   			=			{'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

a		:  Optional[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'''
        ),
    },
}

a		:  str   			=			{
    '''openai/clip-vit-base-patch32''': 7_7,
}




class     UpperCamelCase					(  snake_case__					):
  a    :Optional[Any]      					=				VOCAB_FILES_NAMES
  a    :Union[str, Any]      					=				PRETRAINED_VOCAB_FILES_MAP
  a    :int      					=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  a    :Any      					=				['input_ids', 'attention_mask']
  a    :Dict      					=				CLIPTokenizer



  def __init__( self		,    __lowerCAmelCase=None		,    __lowerCAmelCase=None		,    __lowerCAmelCase=None		,    __lowerCAmelCase="<|endoftext|>"		,    __lowerCAmelCase="<|startoftext|>"		,    __lowerCAmelCase="<|endoftext|>"		,    __lowerCAmelCase="<|endoftext|>"		,    **__lowerCAmelCase		,    ):







      '''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   ):







      '''simple docstring'''


      _a							:       Tuple       					=			self.backend_tokenizer.decode

      def new_decode_method(*__lowerCAmelCase		,    **__lowerCAmelCase   ):
          _a							:       List[Any]       					=			orig_decode_method(*__lowerCAmelCase		,    **__lowerCAmelCase   )
          _a							:       Dict       					=			text.replace(self.backend_tokenizer.model.end_of_word_suffix		,    """ """   ).strip()
          return text

      _a							:       str       					=			new_decode_method



  def 						a_       ( self		,    __lowerCAmelCase		,    __lowerCAmelCase = None   ):







      '''simple docstring'''


      _a							:       Dict       					=			[self.bos_token_id]
      _a							:       Tuple       					=			[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		,    __lowerCAmelCase		,    __lowerCAmelCase = None   ):







      '''simple docstring'''


      _a							:       Dict       					=			[self.bos_token_id]
      _a							:       Optional[Any]       					=			[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		,    __lowerCAmelCase		,    __lowerCAmelCase = None   ):







      '''simple docstring'''


      _a							:       Dict       					=			self._tokenizer.model.save(__lowerCAmelCase		,    name=__lowerCAmelCase   )
      return tuple(__lowerCAmelCase   )








'''simple docstring'''





from __future__ import annotations

from enum import Enum




class     UpperCamelCase					(  snake_case__					):
  a    :Optional[int]      					=				2_4
  a    :Dict      					=				2_1
  a    :Dict      					=				1_8
  a    :int      					=				1_5
  a    :List[str]      					=				1_2
  a    :Tuple      					=				9
  a    :Optional[int]      					=				6
  a    :str      					=				3
  a    :Dict      					=				2
  a    :int      					=				1
  a    :List[Any]      					=				-1
  a    :Optional[Any]      					=				-2
  a    :Union[str, Any]      					=				-3
  a    :int      					=				-6
  a    :Union[str, Any]      					=				-9
  a    :Dict      					=				-1_2
  a    :Any      					=				-1_5
  a    :Tuple      					=				-1_8
  a    :Optional[Any]      					=				-2_1
  a    :Union[str, Any]      					=				-2_4






class     UpperCamelCase					(  snake_case__					):
  a    :Optional[Any]      					=				8
  a    :Optional[int]      					=				7
  a    :Optional[int]      					=				6
  a    :List[str]      					=				5
  a    :Union[str, Any]      					=				4
  a    :Union[str, Any]      					=				3
  a    :str      					=				2
  a    :Optional[int]      					=				1






def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_      ,  ):
    if isinstance(UpperCAmelCase_      ,  UpperCAmelCase_	):
        _a							:       int       					=			SIUnit[known_prefix.lower()]
    if isinstance(UpperCAmelCase_      ,  UpperCAmelCase_	):
        _a							:       Optional[Any]       					=			SIUnit[unknown_prefix.lower()]
    _a							:       float       					=			known_amount * (
        10 ** (known_prefix.value - unknown_prefix.value)
    )
    return unknown_amount





def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_      ,  ):
    if isinstance(UpperCAmelCase_      ,  UpperCAmelCase_	):
        _a							:       Optional[Any]       					=			BinaryUnit[known_prefix.lower()]
    if isinstance(UpperCAmelCase_      ,  UpperCAmelCase_	):
        _a							:       Dict       					=			BinaryUnit[unknown_prefix.lower()]
    _a							:       float       					=			known_amount * (
        2 ** ((known_prefix.value - unknown_prefix.value) * 10)
    )
    return unknown_amount


if __name__ == "__main__":
  import doctest

  doctest.testmod()


