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

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

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




class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      _A  :						Tuple      		=       VOCAB_FILES_NAMES
      _A  :						Optional[Any]      		=       PRETRAINED_VOCAB_FILES_MAP
      _A  :						int      		=       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      _A  :						Dict      		=       ['input_ids', 'attention_mask']
      _A  :						Tuple      		=       CLIPTokenizer
      def __init__(     self						,		lowerCamelCase=None						,		lowerCamelCase=None						,		lowerCamelCase=None						,		lowerCamelCase="<|endoftext|>"						,		lowerCamelCase="<|startoftext|>"						,		lowerCamelCase="<|endoftext|>"						,		lowerCamelCase="<|endoftext|>"						,		**lowerCamelCase						,		):
          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	):
          snake_case__  =			self.backend_tokenizer.decode

          def new_decode_method(*lowerCamelCase						,		**lowerCamelCase	):
              snake_case__  =			orig_decode_method(*lowerCamelCase						,		**lowerCamelCase	)
              snake_case__  =			text.replace(self.backend_tokenizer.model.end_of_word_suffix						,		" "	).strip()
              return text

          snake_case__  =			new_decode_method
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase = None	):
          snake_case__  =			[self.bos_token_id]
          snake_case__  =			[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	):
          snake_case__  =			[self.bos_token_id]
          snake_case__  =			[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	):
          snake_case__  =			self._tokenizer.model.save(lowerCamelCase						,		name=lowerCamelCase	)
          return tuple(lowerCamelCase	)





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__magic_name__           =					logging.get_logger(__name__)

__magic_name__           =					{
    '''MBZUAI/swiftformer-xs''': '''https://huggingface.co/MBZUAI/swiftformer-xs/resolve/main/config.json''',
}




class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      _A  :						Any      		=       'swiftformer'
      def __init__(     self						,		lowerCamelCase=3						,		lowerCamelCase=[3, 3, 6, 4]						,		lowerCamelCase=[48, 56, 1_12, 2_20]						,		lowerCamelCase=4						,		lowerCamelCase=[True, True, True, True]						,		lowerCamelCase="gelu"						,		lowerCamelCase=3						,		lowerCamelCase=2						,		lowerCamelCase=1						,		lowerCamelCase=0.0						,		lowerCamelCase=True						,		lowerCamelCase=1e-5						,		lowerCamelCase=1e-5						,		**lowerCamelCase						,		):
          super().__init__(**lowerCamelCase	)
          snake_case__  =			num_channels
          snake_case__  =			depths
          snake_case__  =			embed_dims
          snake_case__  =			mlp_ratio
          snake_case__  =			downsamples
          snake_case__  =			hidden_act
          snake_case__  =			down_patch_size
          snake_case__  =			down_stride
          snake_case__  =			down_pad
          snake_case__  =			drop_path_rate
          snake_case__  =			use_layer_scale
          snake_case__  =			layer_scale_init_value
          snake_case__  =			batch_norm_eps





class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      _A  :						int      		=       version.parse('1.11'	)
      @property
      def A_     (     self	):
          return OrderedDict(
              [
                  ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
              ]	)



      @property
      def A_     (     self	):
          return 1e-4



