



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

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

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






class 	lowercase		(				snake_case__):






	"""simple docstring"""


	a__   :      Any	     =							VOCAB_FILES_NAMES
	a__   :      Tuple	     =							PRETRAINED_VOCAB_FILES_MAP
	a__   :      List[Any]	     =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	a__   :      List[Any]	     =							["input_ids", "attention_mask"]
	a__   :      Union[str, Any]	     =							CLIPTokenizer




	def __init__(			self			:		Dict		,						__UpperCAmelCase			:		Optional[Any]=None		,						__UpperCAmelCase			:		int=None		,						__UpperCAmelCase			:		Dict=None		,						__UpperCAmelCase			:		Optional[Any]="<|endoftext|>"		,						__UpperCAmelCase			:		int="<|startoftext|>"		,						__UpperCAmelCase			:		Optional[int]="<|endoftext|>"		,						__UpperCAmelCase			:		Optional[Any]="<|endoftext|>"		,						**__UpperCAmelCase			:		List[str]		,						)    ->				str:
							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 						_SCREAMING_SNAKE_CASE	(			self			:		Any  )    ->				List[Any]:
							UpperCAmelCase_=     self.backend_tokenizer.decode

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

							UpperCAmelCase_=     new_decode_method




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









from ...configuration_utils import PretrainedConfig
from ...utils import logging


__A       					=		logging.get_logger(__name__)

__A       					=		{
    '''ZinengTang/tvlt-base''': '''https://huggingface.co/ZinengTang/tvlt-base/blob/main/config.json''',
}






class 	lowercase		(				snake_case__):






	"""simple docstring"""


	a__   :      Tuple	     =							"tvlt"




	def __init__(			self			:		List[str]		,						__UpperCAmelCase			:		List[str]=224		,						__UpperCAmelCase			:		List[str]=2_048		,						__UpperCAmelCase			:		Tuple=128		,						__UpperCAmelCase			:		Union[str, Any]=[16, 16]		,						__UpperCAmelCase			:		str=[16, 16]		,						__UpperCAmelCase			:		str=3		,						__UpperCAmelCase			:		List[str]=1		,						__UpperCAmelCase			:		Tuple=8		,						__UpperCAmelCase			:		Optional[Any]=768		,						__UpperCAmelCase			:		List[Any]=12		,						__UpperCAmelCase			:		Tuple=12		,						__UpperCAmelCase			:		List[str]=3_072		,						__UpperCAmelCase			:		List[Any]="gelu"		,						__UpperCAmelCase			:		str=0.0		,						__UpperCAmelCase			:		str=0.0		,						__UpperCAmelCase			:		List[Any]=0.02		,						__UpperCAmelCase			:		Optional[int]=1E-6		,						__UpperCAmelCase			:		Tuple=True		,						__UpperCAmelCase			:		List[Any]=False		,						__UpperCAmelCase			:		Union[str, Any]=16		,						__UpperCAmelCase			:		Any=512		,						__UpperCAmelCase			:		Optional[Any]=8		,						__UpperCAmelCase			:		Dict=2_048		,						__UpperCAmelCase			:		Dict=0.75		,						__UpperCAmelCase			:		Union[str, Any]=0.15		,						__UpperCAmelCase			:		Any="frame-level"		,						__UpperCAmelCase			:		int=True		,						__UpperCAmelCase			:		List[Any]=True		,						__UpperCAmelCase			:		Union[str, Any]="classification"		,						**__UpperCAmelCase			:		Any		,						)    ->				Tuple:
							super().__init__(**__UpperCAmelCase  )

							if audio_mask_type not in ("frame-level", "patch_level"):
													raise ValueError(
													    """audio_mask_type must be one of two acceptable strategies - {'frame_level', 'patch-level') """
													    F"""got {audio_mask_type}"""  )

							UpperCAmelCase_=     image_size
							UpperCAmelCase_=     spectrogram_length
							UpperCAmelCase_=     frequency_length
							UpperCAmelCase_=     image_patch_size
							UpperCAmelCase_=     audio_patch_size
							UpperCAmelCase_=     num_image_channels
							UpperCAmelCase_=     num_audio_channels
							UpperCAmelCase_=     num_frames

							UpperCAmelCase_=     hidden_size
							UpperCAmelCase_=     num_hidden_layers
							UpperCAmelCase_=     num_attention_heads
							UpperCAmelCase_=     intermediate_size
							UpperCAmelCase_=     hidden_act
							UpperCAmelCase_=     hidden_dropout_prob
							UpperCAmelCase_=     attention_probs_dropout_prob
							UpperCAmelCase_=     initializer_range
							UpperCAmelCase_=     layer_norm_eps
							UpperCAmelCase_=     qkv_bias
							UpperCAmelCase_=     use_mean_pooling

							UpperCAmelCase_=     decoder_num_attention_heads
							UpperCAmelCase_=     decoder_hidden_size
							UpperCAmelCase_=     decoder_num_hidden_layers
							UpperCAmelCase_=     decoder_intermediate_size
							UpperCAmelCase_=     pixel_mask_ratio
							UpperCAmelCase_=     audio_mask_ratio
							UpperCAmelCase_=     audio_mask_type

							UpperCAmelCase_=     task_matching
							UpperCAmelCase_=     task_mae
							UpperCAmelCase_=     loss_type




