






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


_UpperCamelCase :    int      =			logging.get_logger(__name__)

_UpperCamelCase :    Any      =			{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

_UpperCamelCase :    Any      =			{
    """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"""
        ),
    },
}

_UpperCamelCase :    Dict      =			{
    """openai/clip-vit-base-patch32""": 77,
}






class __a ( snake_case_					):
  __lowercase     :     Any       						=       VOCAB_FILES_NAMES
  __lowercase     :     str       						=       PRETRAINED_VOCAB_FILES_MAP
  __lowercase     :     List[str]       						=       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  __lowercase     :     Optional[Any]       						=       ['input_ids', 'attention_mask']
  __lowercase     :     List[str]       						=       CLIPTokenizer



  def __init__(self	:		Dict					,      lowercase_	:		Optional[int]=None					,      lowercase_	:		Tuple=None					,      lowercase_	:		int=None					,      lowercase_	:		Any="<|endoftext|>"					,      lowercase_	:		List[str]="<|startoftext|>"					,      lowercase_	:		List[str]="<|endoftext|>"					,      lowercase_	:		int="<|endoftext|>"					,      **lowercase_	:		int					,      )		->				str:
   super().__init__(
       lowercase_					,      lowercase_					,      tokenizer_file=lowercase_					,      unk_token=lowercase_					,      bos_token=lowercase_					,      eos_token=lowercase_					,      pad_token=lowercase_					,      **lowercase_					,      )

   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	:		Any )		->				List[str]:
   __A						:							List[Any]      =						self.backend_tokenizer.decode

   def new_decode_method(*lowercase_	:		Optional[Any]					,      **lowercase_	:		List[Any] ):
    __A						:							Optional[int]      =						orig_decode_method(*lowercase_					,      **lowercase_ )
    __A						:							List[str]      =						text.replace(self.backend_tokenizer.model.end_of_word_suffix					,      ' ' ).strip()
    return text

   __A						:							Any      =						new_decode_method



  def     A_					(self	:		List[str]					,      lowercase_	:		List[int]					,      lowercase_	:		Optional[List[int]] = None )		->				List[int]:
   __A						:							str      =						[self.bos_token_id]
   __A						:							Any      =						[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					,      lowercase_	:		List[int]					,      lowercase_	:		Optional[List[int]] = None )		->				List[int]:
   __A						:							List[str]      =						[self.bos_token_id]
   __A						:							str      =						[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	:		Tuple					,      lowercase_	:		str					,      lowercase_	:		Optional[str] = None )		->				Tuple[str]:
   __A						:							Tuple      =						self._tokenizer.model.save(lowercase_					,      name=lowercase_ )
   return tuple(lowercase_ )













"""simple docstring"""


import numpy as np

_UpperCamelCase :    int      =			[
    ["""a""", """b""", """c""", """d""", """e"""],
    ["""f""", """g""", """h""", """i""", """k"""],
    ["""l""", """m""", """n""", """o""", """p"""],
    ["""q""", """r""", """s""", """t""", """u"""],
    ["""v""", """w""", """x""", """y""", """z"""],
]






class __a :



  def __init__(self	:		Any )		->				None:
   __A						:							Any      =						np.array(lowercase_ )



  def     A_					(self	:		Dict					,      lowercase_	:		str )		->				np.ndarray:
   __A     ,       __A						:							Any      =						np.where(letter == self.SQUARE )
   __A						:							Tuple      =						np.concatenate([indexa + 1, indexa + 1] )
   return indexes



  def     A_					(self	:		Tuple					,      lowercase_	:		int					,      lowercase_	:		int )		->				str:
   return self.SQUARE[indexa - 1, indexa - 1]



  def     A_					(self	:		Union[str, Any]					,      lowercase_	:		str )		->				str:
   __A						:							Any      =						message.lower()
   __A						:							Optional[Any]      =						message.replace('j'					,      'i' )

   __A						:							Union[str, Any]      =						''
   for letter_index in range(len(lowercase_ ) ):
    if message[letter_index] != " ":
     __A						:							Union[str, Any]      =						self.letter_to_numbers(message[letter_index] )
     __A						:							Union[str, Any]      =						encoded_message + str(numbers[0] ) + str(numbers[1] )
    elif message[letter_index] == " ":
     __A						:							Optional[Any]      =						encoded_message + ' '

   return encoded_message



  def     A_					(self	:		Dict					,      lowercase_	:		str )		->				str:
   __A						:							List[str]      =						message.replace(' '					,      '  ' )
   __A						:							List[Any]      =						''
   for numbers_index in range(int(len(lowercase_ ) / 2 ) ):
    if message[numbers_index * 2] != " ":
     __A						:							Any      =						message[numbers_index * 2]
     __A						:							Tuple      =						message[numbers_index * 2 + 1]

     __A						:							Dict      =						self.numbers_to_letter(int(lowercase_ )					,      int(lowercase_ ) )
     __A						:							Union[str, Any]      =						decoded_message + letter
    elif message[numbers_index * 2] == " ":
     __A						:							int      =						decoded_message + ' '

   return decoded_message





