




import collections
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import (
    is_pt_flax_cross_test,
    require_flax,
    require_torch,
    require_vision,
    slow,
    torch_device,
)
from transformers.utils import is_flax_available, is_torch_available, is_vision_available

from ...test_modeling_flax_common import floats_tensor, ids_tensor, random_attention_mask
from ..bert.test_modeling_flax_bert import FlaxBertModelTester
from ..clip.test_modeling_flax_clip import FlaxCLIPVisionModelTester
from ..vit.test_modeling_flax_vit import FlaxViTModelTester


if is_flax_available():
   from transformers import (
       FlaxBertModel,
       FlaxCLIPVisionModel,
       FlaxVisionTextDualEncoderModel,
       FlaxViTModel,
       VisionTextDualEncoderConfig,
       VisionTextDualEncoderProcessor,
   )
   from transformers.modeling_flax_pytorch_utils import (
       convert_pytorch_state_dict_to_flax,
       load_flax_weights_in_pytorch_model,
   )


if is_torch_available():
   import torch

   from transformers import VisionTextDualEncoderModel

if is_vision_available():
   from PIL import Image

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	Optional[int]							)					-> str:
      if isinstance(__UpperCAmelCase			,			collections.abc.Iterable							):
            return x
      return (x, x)





@require_flax
class        lowerCamelCase_							:


 '''simple docstring'''







 def       lowerCAmelCase_  (							self  :		Union[str, Any]				,				_lowerCAmelCase  :		List[str]				,				_lowerCAmelCase  :		Union[str, Any]						):
       pass



 def       lowerCAmelCase_  (							self  :		Any						):
       pass



 def       lowerCAmelCase_  (							self  :		Tuple						):
       pass



 def       lowerCAmelCase_  (							self  :		List[str]				,				_lowerCAmelCase  :		np.ndarray				,				_lowerCAmelCase  :		np.ndarray				,				_lowerCAmelCase  :		float						):
       SCREAMING_SNAKE_CASE_							=			np.abs((a - b)						).max()
       self.assertLessEqual(_lowerCAmelCase				,				_lowerCAmelCase				,				F"Difference between torch and flax is {diff} (>= {tol})."						)



 def       lowerCAmelCase_  (							self  :		Union[str, Any]				,				_lowerCAmelCase  :		Dict				,				_lowerCAmelCase  :		Union[str, Any]				,				_lowerCAmelCase  :		Tuple				,				_lowerCAmelCase  :		Optional[Any]				,				_lowerCAmelCase  :		List[Any]=None				,				**_lowerCAmelCase  :		str						):
       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderConfig.from_vision_text_configs(_lowerCAmelCase				,				_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel(_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			model(input_ids=_lowerCAmelCase				,				pixel_values=_lowerCAmelCase				,				attention_mask=_lowerCAmelCase						)

       self.assertEqual(output['text_embeds'].shape				,				(input_ids.shape[0], config.projection_dim)						)
       self.assertEqual(output['image_embeds'].shape				,				(pixel_values.shape[0], config.projection_dim)						)



 def       lowerCAmelCase_  (							self  :		List[Any]				,				_lowerCAmelCase  :		Tuple				,				_lowerCAmelCase  :		Any				,				_lowerCAmelCase  :		List[Any]				,				_lowerCAmelCase  :		str				,				_lowerCAmelCase  :		List[Any]=None				,				**_lowerCAmelCase  :		str						):
       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			self.get_vision_text_model(_lowerCAmelCase				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			{'vision_model': vision_model, 'text_model': text_model}
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_vision_text_pretrained(**_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			model(input_ids=_lowerCAmelCase				,				pixel_values=_lowerCAmelCase				,				attention_mask=_lowerCAmelCase						)

       self.assertEqual(output['text_embeds'].shape				,				(input_ids.shape[0], model.config.projection_dim)						)
       self.assertEqual(output['image_embeds'].shape				,				(pixel_values.shape[0], model.config.projection_dim)						)



 def       lowerCAmelCase_  (							self  :		Optional[int]				,				_lowerCAmelCase  :		Any				,				_lowerCAmelCase  :		Tuple				,				_lowerCAmelCase  :		Dict				,				_lowerCAmelCase  :		str				,				_lowerCAmelCase  :		List[Any]=None				,				**_lowerCAmelCase  :		List[str]						):
       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			self.get_vision_text_model(_lowerCAmelCase				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			{'vision_model': vision_model, 'text_model': text_model}
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_vision_text_pretrained(**_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			model(input_ids=_lowerCAmelCase				,				pixel_values=_lowerCAmelCase				,				attention_mask=_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			output[0]

       with tempfile.TemporaryDirectory() as tmpdirname:
             model.save_pretrained(_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_pretrained(_lowerCAmelCase						)

             SCREAMING_SNAKE_CASE_							=			model(input_ids=_lowerCAmelCase				,				pixel_values=_lowerCAmelCase				,				attention_mask=_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			after_output[0]
             SCREAMING_SNAKE_CASE_							=			np.amax(np.abs(out_a - out_a						)						)
             self.assertLessEqual(_lowerCAmelCase				,				1E-3						)



 def       lowerCAmelCase_  (							self  :		Union[str, Any]				,				_lowerCAmelCase  :		List[str]				,				_lowerCAmelCase  :		Dict				,				_lowerCAmelCase  :		Optional[Any]				,				_lowerCAmelCase  :		Optional[int]				,				_lowerCAmelCase  :		Any=None				,				**_lowerCAmelCase  :		List[str]						):
       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			self.get_vision_text_model(_lowerCAmelCase				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			{'vision_model': vision_model, 'text_model': text_model}
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_vision_text_pretrained(**_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			model(
           input_ids=_lowerCAmelCase				,				pixel_values=_lowerCAmelCase				,				attention_mask=_lowerCAmelCase				,				output_attentions=_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			output.vision_model_output.attentions
       self.assertEqual(len(_lowerCAmelCase						)				,				vision_config.num_hidden_layers						)

       # in ViT, the seq_len equals the number of patches + 1 (we add 1 for the [CLS] token)
       SCREAMING_SNAKE_CASE_							=			to_atuple(vision_model.config.image_size						)
       SCREAMING_SNAKE_CASE_							=			to_atuple(vision_model.config.patch_size						)
       SCREAMING_SNAKE_CASE_							=			(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
       SCREAMING_SNAKE_CASE_							=			num_patches + 1
       self.assertEqual(vision_attentions[0].shape[-3:]				,				(vision_config.num_attention_heads, seq_len, seq_len)						)

       SCREAMING_SNAKE_CASE_							=			output.text_model_output.attentions
       self.assertEqual(len(_lowerCAmelCase						)				,				text_config.num_hidden_layers						)

       self.assertEqual(
           text_attentions[0].shape[-3:]				,				(text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1])				,				)



 def       lowerCAmelCase_  (							self  :		Dict				,				_lowerCAmelCase  :		Dict				,				_lowerCAmelCase  :		int				,				_lowerCAmelCase  :		int						):
       pt_model.to(_lowerCAmelCase						)
       pt_model.eval()

       # prepare inputs
       SCREAMING_SNAKE_CASE_							=			inputs_dict
       SCREAMING_SNAKE_CASE_							=			{k: torch.tensor(v.tolist()						) for k, v in flax_inputs.items()}

       with torch.no_grad():
             SCREAMING_SNAKE_CASE_							=			pt_model(**_lowerCAmelCase						).to_tuple()

       SCREAMING_SNAKE_CASE_							=			fx_model(**_lowerCAmelCase						).to_tuple()
       self.assertEqual(len(_lowerCAmelCase						)				,				len(_lowerCAmelCase						)				,				'Output lengths differ between Flax and PyTorch'						)
       for fx_output, pt_output in zip(fx_outputs[:4]				,				pt_outputs[:4]						):
             self.assert_almost_equals(_lowerCAmelCase				,				pt_output.numpy()				,				4E-2						)

       # PT -> Flax
       with tempfile.TemporaryDirectory() as tmpdirname:
             pt_model.save_pretrained(_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_pretrained(_lowerCAmelCase				,				from_pt=_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			fx_model_loaded(**_lowerCAmelCase						).to_tuple()
       self.assertEqual(len(_lowerCAmelCase						)				,				len(_lowerCAmelCase						)				,				'Output lengths differ between Flax and PyTorch'						)
       for fx_output_loaded, pt_output in zip(fx_outputs_loaded[:4]				,				pt_outputs[:4]						):
             self.assert_almost_equals(_lowerCAmelCase				,				pt_output.numpy()				,				4E-2						)

       # Flax -> PT
       with tempfile.TemporaryDirectory() as tmpdirname:
             fx_model.save_pretrained(_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderModel.from_pretrained(_lowerCAmelCase				,				from_flax=_lowerCAmelCase						)

       pt_model_loaded.to(_lowerCAmelCase						)
       pt_model_loaded.eval()

       with torch.no_grad():
             SCREAMING_SNAKE_CASE_							=			pt_model_loaded(**_lowerCAmelCase						).to_tuple()

       self.assertEqual(len(_lowerCAmelCase						)				,				len(_lowerCAmelCase						)				,				'Output lengths differ between Flax and PyTorch'						)
       for fx_output, pt_output_loaded in zip(fx_outputs[:4]				,				pt_outputs_loaded[:4]						):
             self.assert_almost_equals(_lowerCAmelCase				,				pt_output_loaded.numpy()				,				4E-2						)



 def       lowerCAmelCase_  (							self  :		Optional[int]				,				_lowerCAmelCase  :		List[Any]				,				_lowerCAmelCase  :		List[Any]				,				_lowerCAmelCase  :		List[str]						):
       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderConfig.from_vision_text_configs(_lowerCAmelCase				,				_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderModel(_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel(_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			convert_pytorch_state_dict_to_flax(pt_model.state_dict()				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			fx_state

       self.check_pt_flax_equivalence(_lowerCAmelCase				,				_lowerCAmelCase				,				_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		Tuple				,				_lowerCAmelCase  :		int				,				_lowerCAmelCase  :		Optional[int]				,				_lowerCAmelCase  :		List[Any]						):
       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderConfig.from_vision_text_configs(_lowerCAmelCase				,				_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderModel(_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel(_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			load_flax_weights_in_pytorch_model(_lowerCAmelCase				,				fx_model.params						)

       self.check_pt_flax_equivalence(_lowerCAmelCase				,				_lowerCAmelCase				,				_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		List[Any]						):
       SCREAMING_SNAKE_CASE_							=			self.prepare_config_and_inputs()
       self.check_model_from_pretrained_configs(**_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		Dict						):
       SCREAMING_SNAKE_CASE_							=			self.prepare_config_and_inputs()
       self.check_vision_text_dual_encoder_from_pretrained(**_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		str						):
       SCREAMING_SNAKE_CASE_							=			self.prepare_config_and_inputs()
       self.check_save_load(**_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		int						):
       SCREAMING_SNAKE_CASE_							=			self.prepare_config_and_inputs()
       self.check_vision_text_output_attention(**_lowerCAmelCase						)



 @is_pt_flax_cross_test
 def       lowerCAmelCase_  (							self  :		Tuple						):
       SCREAMING_SNAKE_CASE_							=			self.prepare_config_and_inputs()
       SCREAMING_SNAKE_CASE_							=			config_inputs_dict.pop('vision_config'						)
       SCREAMING_SNAKE_CASE_							=			config_inputs_dict.pop('text_config'						)

       SCREAMING_SNAKE_CASE_							=			config_inputs_dict

       self.check_equivalence_pt_to_flax(_lowerCAmelCase				,				_lowerCAmelCase				,				_lowerCAmelCase						)
       self.check_equivalence_flax_to_pt(_lowerCAmelCase				,				_lowerCAmelCase				,				_lowerCAmelCase						)




 @slow
 def       lowerCAmelCase_  (							self  :		Any						):
       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			self.get_pretrained_model_and_inputs()

       SCREAMING_SNAKE_CASE_							=			model_a(**_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			outputs[0]

       with tempfile.TemporaryDirectory() as tmp_dirname:
             model_a.save_pretrained(_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_pretrained(_lowerCAmelCase						)

             SCREAMING_SNAKE_CASE_							=			model_a(**_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_							=			after_outputs[0]
             SCREAMING_SNAKE_CASE_							=			np.amax(np.abs(out_a - out_a						)						)
             self.assertLessEqual(_lowerCAmelCase				,				1E-5						)





@require_flax
class        lowerCamelCase_							(      _SCREAMING_SNAKE_CASE       ,   unittest.TestCase					):


 '''simple docstring'''







 def       lowerCAmelCase_  (							self  :		Union[str, Any]						):
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_vision_text_pretrained(
           'hf-internal-testing/tiny-random-vit'				,				'hf-internal-testing/tiny-bert'				,				vision_from_pt=_lowerCAmelCase				,				text_from_pt=_lowerCAmelCase				,				)
       SCREAMING_SNAKE_CASE_							=			13
       SCREAMING_SNAKE_CASE_							=			floats_tensor(
           [
               batch_size,
               model.config.vision_config.num_channels,
               model.config.vision_config.image_size,
               model.config.vision_config.image_size,
           ]						)
       SCREAMING_SNAKE_CASE_							=			ids_tensor([batch_size, 4]				,				model.config.text_config.vocab_size						)
       SCREAMING_SNAKE_CASE_							=			random_attention_mask([batch_size, 4]						)
       SCREAMING_SNAKE_CASE_							=			{'pixel_values': pixel_values, 'input_ids': input_ids, 'attention_mask': attention_mask}

       return model, inputs



 def       lowerCAmelCase_  (							self  :		Union[str, Any]				,				_lowerCAmelCase  :		Tuple				,				_lowerCAmelCase  :		Any						):
       SCREAMING_SNAKE_CASE_							=			FlaxViTModel(_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			FlaxBertModel(_lowerCAmelCase						)
       return vision_model, text_model




 def       lowerCAmelCase_  (							self  :		List[Any]						):
       SCREAMING_SNAKE_CASE_							=			FlaxViTModelTester(self						)
       SCREAMING_SNAKE_CASE_							=			FlaxBertModelTester(self						)
       SCREAMING_SNAKE_CASE_							=			vit_model_tester.prepare_config_and_inputs()
       SCREAMING_SNAKE_CASE_							=			bert_model_tester.prepare_config_and_inputs()

       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			vision_config_and_inputs

       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			text_config_and_inputs

       # make sure that cross attention layers are added
       return {
           "text_config": text_config,
           "vision_config": vision_config,
           "pixel_values": pixel_values,
           "attention_mask": attention_mask,
           "input_ids": input_ids,
           "token_type_ids": token_type_ids,
       }





@require_torch
class        lowerCamelCase_							(      _SCREAMING_SNAKE_CASE       ,   unittest.TestCase					):


 '''simple docstring'''







 def       lowerCAmelCase_  (							self  :		Union[str, Any]						):
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_vision_text_pretrained(
           'hf-internal-testing/tiny-random-clip'				,				'hf-internal-testing/tiny-bert'				,				vision_from_pt=_lowerCAmelCase				,				text_from_pt=_lowerCAmelCase				,				)
       SCREAMING_SNAKE_CASE_							=			13
       SCREAMING_SNAKE_CASE_							=			floats_tensor(
           [
               batch_size,
               model.config.vision_config.num_channels,
               model.config.vision_config.image_size,
               model.config.vision_config.image_size,
           ]						)
       SCREAMING_SNAKE_CASE_							=			ids_tensor([batch_size, 4]				,				model.config.text_config.vocab_size						)
       SCREAMING_SNAKE_CASE_							=			random_attention_mask([batch_size, 4]						)
       SCREAMING_SNAKE_CASE_							=			{'pixel_values': pixel_values, 'input_ids': input_ids, 'attention_mask': attention_mask}

       return model, inputs



 def       lowerCAmelCase_  (							self  :		Any				,				_lowerCAmelCase  :		Union[str, Any]				,				_lowerCAmelCase  :		int						):
       SCREAMING_SNAKE_CASE_							=			FlaxCLIPVisionModel(_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			FlaxBertModel(_lowerCAmelCase						)
       return vision_model, text_model




 def       lowerCAmelCase_  (							self  :		Optional[Any]						):
       SCREAMING_SNAKE_CASE_							=			FlaxCLIPVisionModelTester(self						)
       SCREAMING_SNAKE_CASE_							=			FlaxBertModelTester(self						)
       SCREAMING_SNAKE_CASE_							=			clip_model_tester.prepare_config_and_inputs()
       SCREAMING_SNAKE_CASE_							=			bert_model_tester.prepare_config_and_inputs()

       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			vision_config_and_inputs

       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							=			text_config_and_inputs

       # make sure that cross attention layers are added
       return {
           "text_config": text_config,
           "vision_config": vision_config,
           "pixel_values": pixel_values,
           "attention_mask": attention_mask,
           "input_ids": input_ids,
           "token_type_ids": token_type_ids,
       }





@require_flax
@require_vision
class        lowerCamelCase_							(      unittest.TestCase					):


 '''simple docstring'''







 @slow
 def       lowerCAmelCase_  (							self  :		Any						):
       SCREAMING_SNAKE_CASE_							=			FlaxVisionTextDualEncoderModel.from_pretrained('clip-italian/clip-italian'				,				logit_scale_init_value=1.0						)
       SCREAMING_SNAKE_CASE_							=			VisionTextDualEncoderProcessor.from_pretrained('clip-italian/clip-italian'						)

       SCREAMING_SNAKE_CASE_							=			Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'						)
       SCREAMING_SNAKE_CASE_							=			processor(
           text=['una foto di un gatto', 'una foto di un cane']				,				images=_lowerCAmelCase				,				padding=_lowerCAmelCase				,				return_tensors='np'						)

       SCREAMING_SNAKE_CASE_							=			model(**_lowerCAmelCase						)

       # verify the logits
       self.assertEqual(outputs.logits_per_image.shape				,				(inputs.pixel_values.shape[0], inputs.input_ids.shape[0])						)
       self.assertEqual(
           outputs.logits_per_text.shape				,				(inputs.input_ids.shape[0], inputs.pixel_values.shape[0])				,				)

       SCREAMING_SNAKE_CASE_							=			np.array([[1.228_4727, 0.310_4122]]						)

       self.assertTrue(np.allclose(outputs.logits_per_image				,				_lowerCAmelCase				,				atol=1E-3						)						)





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_squeezebert import SqueezeBertTokenizer


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

lowerCamelCase__ :   Dict					=							{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

lowerCamelCase__ :   Tuple					=							{
    'vocab_file': {
        'squeezebert/squeezebert-uncased': (
            'https://huggingface.co/squeezebert/squeezebert-uncased/resolve/main/vocab.txt'
        ),
        'squeezebert/squeezebert-mnli': 'https://huggingface.co/squeezebert/squeezebert-mnli/resolve/main/vocab.txt',
        'squeezebert/squeezebert-mnli-headless': (
            'https://huggingface.co/squeezebert/squeezebert-mnli-headless/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'squeezebert/squeezebert-uncased': (
            'https://huggingface.co/squeezebert/squeezebert-uncased/resolve/main/tokenizer.json'
        ),
        'squeezebert/squeezebert-mnli': (
            'https://huggingface.co/squeezebert/squeezebert-mnli/resolve/main/tokenizer.json'
        ),
        'squeezebert/squeezebert-mnli-headless': (
            'https://huggingface.co/squeezebert/squeezebert-mnli-headless/resolve/main/tokenizer.json'
        ),
    },
}

lowerCamelCase__ :   int					=							{
    'squeezebert/squeezebert-uncased': 512,
    'squeezebert/squeezebert-mnli': 512,
    'squeezebert/squeezebert-mnli-headless': 512,
}


lowerCamelCase__ :   str					=							{
    'squeezebert/squeezebert-uncased': {'do_lower_case': True},
    'squeezebert/squeezebert-mnli': {'do_lower_case': True},
    'squeezebert/squeezebert-mnli-headless': {'do_lower_case': True},
}





class        lowerCamelCase_							(      _SCREAMING_SNAKE_CASE					):


 '''simple docstring'''







 lowercase_				    =    VOCAB_FILES_NAMES
 lowercase_				    =    PRETRAINED_VOCAB_FILES_MAP
 lowercase_				    =    PRETRAINED_INIT_CONFIGURATION
 lowercase_				    =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 lowercase_				    =    SqueezeBertTokenizer



 def __init__(							self  :		Tuple				,				_lowerCAmelCase  :		Dict=None				,				_lowerCAmelCase  :		int=None				,				_lowerCAmelCase  :		List[str]=True				,				_lowerCAmelCase  :		str="[UNK]"				,				_lowerCAmelCase  :		Union[str, Any]="[SEP]"				,				_lowerCAmelCase  :		List[Any]="[PAD]"				,				_lowerCAmelCase  :		str="[CLS]"				,				_lowerCAmelCase  :		Dict="[MASK]"				,				_lowerCAmelCase  :		Optional[int]=True				,				_lowerCAmelCase  :		Dict=None				,				**_lowerCAmelCase  :		str				,				):
       super().__init__(
           _lowerCAmelCase				,				tokenizer_file=_lowerCAmelCase				,				do_lower_case=_lowerCAmelCase				,				unk_token=_lowerCAmelCase				,				sep_token=_lowerCAmelCase				,				pad_token=_lowerCAmelCase				,				cls_token=_lowerCAmelCase				,				mask_token=_lowerCAmelCase				,				tokenize_chinese_chars=_lowerCAmelCase				,				strip_accents=_lowerCAmelCase				,				**_lowerCAmelCase				,				)

       SCREAMING_SNAKE_CASE_							=			json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
       if (
           normalizer_state.get('lowercase'				,				_lowerCAmelCase						) != do_lower_case
           or normalizer_state.get('strip_accents'				,				_lowerCAmelCase						) != strip_accents
           or normalizer_state.get('handle_chinese_chars'				,				_lowerCAmelCase						) != tokenize_chinese_chars
       ):
             SCREAMING_SNAKE_CASE_							=			getattr(_lowerCAmelCase				,				normalizer_state.pop('type'						)						)
             SCREAMING_SNAKE_CASE_							=			do_lower_case
             SCREAMING_SNAKE_CASE_							=			strip_accents
             SCREAMING_SNAKE_CASE_							=			tokenize_chinese_chars
             SCREAMING_SNAKE_CASE_							=			normalizer_class(**_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			do_lower_case



 def       lowerCAmelCase_  (							self  :		Tuple				,				_lowerCAmelCase  :		str				,				_lowerCAmelCase  :		Optional[int]=None						):
       SCREAMING_SNAKE_CASE_							=			[self.cls_token_id] + token_ids_a + [self.sep_token_id]

       if token_ids_a:
             output += token_ids_a + [self.sep_token_id]

       return output



 def       lowerCAmelCase_  (							self  :		Optional[int]				,				_lowerCAmelCase  :		List[int]				,				_lowerCAmelCase  :		Optional[List[int]] = None						):
       SCREAMING_SNAKE_CASE_							=			[self.sep_token_id]
       SCREAMING_SNAKE_CASE_							=			[self.cls_token_id]
       if token_ids_a is None:
             return len(cls + token_ids_a + sep						) * [0]
       return len(cls + token_ids_a + sep						) * [0] + len(token_ids_a + sep						) * [1]




 def       lowerCAmelCase_  (							self  :		Tuple				,				_lowerCAmelCase  :		str				,				_lowerCAmelCase  :		Optional[str] = None						):
       SCREAMING_SNAKE_CASE_							=			self._tokenizer.model.save(_lowerCAmelCase				,				name=_lowerCAmelCase						)
       return tuple(_lowerCAmelCase						)