






"""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					=     logging.get_logger(__name__)

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

UpperCamelCase					=     {
    """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					=     {
    """openai/clip-vit-base-patch32""": 77,
}







class 						_a  (		lowercase_       ):





   '''simple docstring'''






   UpperCamelCase__     	=							VOCAB_FILES_NAMES
   UpperCamelCase__     	=							PRETRAINED_VOCAB_FILES_MAP
   UpperCamelCase__     	=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   UpperCamelCase__     	=							["""input_ids""", """attention_mask"""]
   UpperCamelCase__     	=							CLIPTokenizer





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




          '''simple docstring'''




          super().__init__(
              UpperCAmelCase_					, UpperCAmelCase_					, tokenizer_file=UpperCAmelCase_					, unk_token=UpperCAmelCase_					, bos_token=UpperCAmelCase_					, eos_token=UpperCAmelCase_					, pad_token=UpperCAmelCase_					, **UpperCAmelCase_					, )

          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 __lowercase							(       self)			->   Tuple:




          '''simple docstring'''




          lowercase__:							Union[str, Any]         =     self.backend_tokenizer.decode

          def new_decode_method(*UpperCAmelCase_					, **UpperCAmelCase_):
                 lowercase__:							Union[str, Any]         =     orig_decode_method(*UpperCAmelCase_					, **UpperCAmelCase_)
                 lowercase__:							Optional[Any]         =     text.replace(self.backend_tokenizer.model.end_of_word_suffix					, " ").strip()
                 return text

          lowercase__:							List[str]         =     new_decode_method





   def __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_ = None)			->   List[int]:




          '''simple docstring'''




          lowercase__:							List[str]         =     [self.bos_token_id]
          lowercase__:							Dict         =     [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 __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_ = None)			->   List[int]:




          '''simple docstring'''




          lowercase__:							str         =     [self.bos_token_id]
          lowercase__:							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 __lowercase							(       self					, UpperCAmelCase_					, UpperCAmelCase_ = None)			->   Tuple[str]:




          '''simple docstring'''




          lowercase__:							str         =     self._tokenizer.model.save(UpperCAmelCase_					, name=UpperCAmelCase_)
          return tuple(UpperCAmelCase_)













from typing import TYPE_CHECKING

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


UpperCamelCase__ :			Union[str, Any]       	=			{
    """configuration_mobilevitv2""": [
        """MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """MobileViTV2Config""",
        """MobileViTV2OnnxConfig""",
    ],
}


try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCamelCase__ :			int       	=			[
				    """MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """MobileViTV2ForImageClassification""",
				    """MobileViTV2ForSemanticSegmentation""",
				    """MobileViTV2Model""",
				    """MobileViTV2PreTrainedModel""",
				]

if TYPE_CHECKING:
				from .configuration_mobilevitva import (
				    MOBILEVITV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    MobileViTVaConfig,
				    MobileViTVaOnnxConfig,
				)

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_mobilevitva import (
								    MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
								    MobileViTVaForImageClassification,
								    MobileViTVaForSemanticSegmentation,
								    MobileViTVaModel,
								    MobileViTVaPreTrainedModel,
								)

else:
				import sys

				UpperCamelCase__ :			List[Any]       	=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


