




'''simple docstring'''





import inspect
import unittest
import warnings
from typing import List

from transformers import EfficientFormerConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch

       from transformers import (
           MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
           MODEL_MAPPING,
           EfficientFormerForImageClassification,
           EfficientFormerForImageClassificationWithTeacher,
           EfficientFormerModel,
       )
       from transformers.models.efficientformer.modeling_efficientformer import (
           EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
       )


if is_vision_available():
       from PIL import Image

       from transformers import EfficientFormerImageProcessor






class 						lowercase     :






      def __init__(self ,  a__ ,  a__ = 1_3 ,  a__ = 6_4 ,  a__ = 2 ,  a__ = 3 ,  a__ = 3 ,  a__ = True ,  a__ = True ,  a__ = 1_2_8 ,  a__=[1_6, 3_2, 6_4, 1_2_8] ,  a__ = 7 ,  a__ = 4 ,  a__ = 3_7 ,  a__ = "gelu" ,  a__ = 0.1 ,  a__ = 0.1 ,  a__ = 1_0 ,  a__ = 0.02 ,  a__ = 2 ,  a__ = 1 ,  a__ = 1_2_8 ,  a__ = [2, 2, 2, 2] ,  a__ = 2 ,  a__ = 2 ,  )       ->   int:
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= parent
         SCREAMING_SNAKE_CASE__			:				str       						= batch_size
         SCREAMING_SNAKE_CASE__			:				List[str]       						= image_size
         SCREAMING_SNAKE_CASE__			:				List[str]       						= patch_size
         SCREAMING_SNAKE_CASE__			:				List[str]       						= num_channels
         SCREAMING_SNAKE_CASE__			:				Any       						= is_training
         SCREAMING_SNAKE_CASE__			:				List[str]       						= use_labels
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= hidden_size
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= num_hidden_layers
         SCREAMING_SNAKE_CASE__			:				Any       						= num_attention_heads
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= intermediate_size
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= hidden_act
         SCREAMING_SNAKE_CASE__			:				Any       						= hidden_dropout_prob
         SCREAMING_SNAKE_CASE__			:				Dict       						= attention_probs_dropout_prob
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= type_sequence_label_size
         SCREAMING_SNAKE_CASE__			:				Tuple       						= initializer_range
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= encoder_stride
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= num_attention_outputs
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= embed_dim
         SCREAMING_SNAKE_CASE__			:				str       						= embed_dim + 1
         SCREAMING_SNAKE_CASE__			:				Tuple       						= resolution
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= depths
         SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_sizes
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= dim
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= mlp_expansion_ratio






      def    A__(self					)       ->   Tuple:
         SCREAMING_SNAKE_CASE__			:				str       						= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

         SCREAMING_SNAKE_CASE__			:				Dict       						= None
         if self.use_labels:
            SCREAMING_SNAKE_CASE__			:				Tuple       						= ids_tensor([self.batch_size] ,  self.type_sequence_label_size					)

         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.get_config()
         return config, pixel_values, labels






      def    A__(self					)       ->   Optional[Any]:
         return EfficientFormerConfig(
             image_size=self.image_size ,  patch_size=self.patch_size ,  num_channels=self.num_channels ,  hidden_size=self.hidden_size ,  num_hidden_layers=self.num_hidden_layers ,  num_attention_heads=self.num_attention_heads ,  intermediate_size=self.intermediate_size ,  hidden_act=self.hidden_act ,  hidden_dropout_prob=self.hidden_dropout_prob ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob ,  is_decoder=a__ ,  initializer_range=self.initializer_range ,  encoder_stride=self.encoder_stride ,  resolution=self.resolution ,  depths=self.depths ,  hidden_sizes=self.hidden_sizes ,  dim=self.dim ,  mlp_expansion_ratio=self.mlp_expansion_ratio ,  )






      def    A__(self ,  a__ ,  a__ ,  a__					)       ->   str:
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= EfficientFormerModel(config=a__					)
         model.to(a__					)
         model.eval()
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= model(a__					)
         self.parent.assertEqual(result.last_hidden_state.shape ,  (self.batch_size, self.seq_length, self.hidden_size)					)






      def    A__(self ,  a__ ,  a__ ,  a__					)       ->   str:
         SCREAMING_SNAKE_CASE__			:				str       						= self.type_sequence_label_size
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= EfficientFormerForImageClassification(a__					)
         model.to(a__					)
         model.eval()
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= model(a__ ,  labels=a__					)
         self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.type_sequence_label_size)					)

         # test greyscale images
         SCREAMING_SNAKE_CASE__			:				Any       						= 1
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= EfficientFormerForImageClassification(a__					)
         model.to(a__					)
         model.eval()

         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
         SCREAMING_SNAKE_CASE__			:				Dict       						= model(a__					)
         self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.type_sequence_label_size)					)






      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.prepare_config_and_inputs()
         (
             SCREAMING_SNAKE_CASE__				
         )			:				Optional[int]       						= config_and_inputs
         SCREAMING_SNAKE_CASE__			:				List[str]       						= {'''pixel_values''': pixel_values}
         return config, inputs_dict






@require_torch
class 						lowercase     (   UpperCAmelCase_				,			UpperCAmelCase_				,			unittest.TestCase):
      __lowercase 		=  (
          (
              EfficientFormerModel,
              EfficientFormerForImageClassificationWithTeacher,
              EfficientFormerForImageClassification,
          )
          if is_torch_available()
          else ()
      )
      __lowercase 		=  (
          {
              '''feature-extraction''': EfficientFormerModel,
              '''image-classification''': (
                  EfficientFormerForImageClassification,
                  EfficientFormerForImageClassificationWithTeacher,
              ),
          }
          if is_torch_available()
          else {}
      )
      __lowercase 		=  False

      __lowercase 		=  False
      __lowercase 		=  False
      __lowercase 		=  False






      def    A__(self					)       ->   List[str]:
         SCREAMING_SNAKE_CASE__			:				Dict       						= EfficientFormerModelTester(self					)
         SCREAMING_SNAKE_CASE__			:				Dict       						= ConfigTester(
             self ,  config_class=a__ ,  has_text_modality=a__ ,  hidden_size=3_7					)






      def    A__(self					)       ->   Tuple:
         self.config_tester.run_common_tests()






      @unittest.skip(reason='''EfficientFormer does not use inputs_embeds'''					)
      def    A__(self					)       ->   Any:
         pass






      @unittest.skip(reason='''EfficientFormer does not support input and output embeddings'''					)
      def    A__(self					)       ->   Optional[int]:
         pass






      def    A__(self					)       ->   Dict:
         SCREAMING_SNAKE_CASE__			:				int       						= self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
            SCREAMING_SNAKE_CASE__			:				str       						= model_class(a__					)
            SCREAMING_SNAKE_CASE__			:				Tuple       						= inspect.signature(model.forward					)
            # signature.parameters is an OrderedDict => so arg_names order is deterministic
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= [*signature.parameters.keys()]

            SCREAMING_SNAKE_CASE__			:				int       						= ['''pixel_values''']
            self.assertListEqual(arg_names[:1] ,  a__					)






      def    A__(self					)       ->   List[Any]:
         def check_hidden_states_output(a__ ,  a__ ,  a__					):
            SCREAMING_SNAKE_CASE__			:				List[str]       						= model_class(a__					)
            model.to(a__					)
            model.eval()

            with torch.no_grad():
               SCREAMING_SNAKE_CASE__			:				List[str]       						= model(**self._prepare_for_class(a__ ,  a__					)					)

            SCREAMING_SNAKE_CASE__			:				int       						= outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= getattr(
                self.model_tester ,  '''expected_num_hidden_layers''' ,  self.model_tester.num_hidden_layers + 1					)
            self.assertEqual(len(a__					) ,  a__					)

            if hasattr(self.model_tester ,  '''encoder_seq_length'''					):
               SCREAMING_SNAKE_CASE__			:				List[str]       						= self.model_tester.encoder_seq_length
               if hasattr(self.model_tester ,  '''chunk_length'''					) and self.model_tester.chunk_length > 1:
                  SCREAMING_SNAKE_CASE__			:				Any       						= seq_length * self.model_tester.chunk_length
            else:
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.model_tester.seq_length

            self.assertListEqual(
                list(hidden_states[-1].shape[-2:]					) ,  [seq_length, self.model_tester.hidden_size] ,  )

            if config.is_encoder_decoder:
               SCREAMING_SNAKE_CASE__			:				Optional[int]       						= outputs.decoder_hidden_states

               self.assertIsInstance(a__ ,  (list, tuple)					)
               self.assertEqual(len(a__					) ,  a__					)
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= getattr(self.model_tester ,  '''seq_length''' ,  a__					)
               SCREAMING_SNAKE_CASE__			:				Dict       						= getattr(self.model_tester ,  '''decoder_seq_length''' ,  a__					)

               self.assertListEqual(
                   list(hidden_states[-1].shape[-2:]					) ,  [decoder_seq_length, self.model_tester.hidden_size] ,  )

         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= True
            check_hidden_states_output(a__ ,  a__ ,  a__					)

            # check that output_hidden_states also work using config
            del inputs_dict["output_hidden_states"]
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= True

            check_hidden_states_output(a__ ,  a__ ,  a__					)






      def    A__(self ,  a__ ,  a__ ,  a__=False					)       ->   Union[str, Any]:
         SCREAMING_SNAKE_CASE__			:				int       						= super()._prepare_for_class(a__ ,  a__ ,  return_labels=a__					)

         if return_labels:
            if model_class.__name__ == "EfficientFormerForImageClassificationWithTeacher":
               del inputs_dict["labels"]

         return inputs_dict






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				Tuple       						= self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*a__					)






      @unittest.skip(reason='''EfficientFormer does not implement masked image modeling yet'''					)
      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				Any       						= self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_image_modeling(*a__					)






      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_image_classification(*a__					)






      def    A__(self					)       ->   List[Any]:
         if not self.model_tester.is_training:
            return

         SCREAMING_SNAKE_CASE__			:				Tuple       						= self.model_tester.prepare_config_and_inputs_for_common()
         SCREAMING_SNAKE_CASE__			:				int       						= True

         for model_class in self.all_model_classes:
            # EfficientFormerForImageClassificationWithTeacher supports inference-only
            if (
                model_class in get_values(a__					)
                or model_class.__name__ == "EfficientFormerForImageClassificationWithTeacher"
            ):
               continue
            SCREAMING_SNAKE_CASE__			:				int       						= model_class(a__					)
            model.to(a__					)
            model.train()
            SCREAMING_SNAKE_CASE__			:				Dict       						= self._prepare_for_class(a__ ,  a__ ,  return_labels=a__					)
            SCREAMING_SNAKE_CASE__			:				Tuple       						= model(**a__					).loss
            loss.backward()






      def    A__(self					)       ->   str:
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.model_tester.prepare_config_and_inputs_for_common()

         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= [
             {'''title''': '''multi_label_classification''', '''num_labels''': 2, '''dtype''': torch.float},
             {'''title''': '''single_label_classification''', '''num_labels''': 1, '''dtype''': torch.long},
             {'''title''': '''regression''', '''num_labels''': 1, '''dtype''': torch.float},
         ]

         for model_class in self.all_model_classes:
            if (
                model_class
                not in [
                    *get_values(a__					),
                ]
                or model_class.__name__ == "EfficientFormerForImageClassificationWithTeacher"
            ):
               continue

            for problem_type in problem_types:
               with self.subTest(msg=f"""Testing {model_class} with {problem_type["title"]}"""					):
                  SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= problem_type['''title''']
                  SCREAMING_SNAKE_CASE__			:				Tuple       						= problem_type['''num_labels''']

                  SCREAMING_SNAKE_CASE__			:				List[Any]       						= model_class(a__					)
                  model.to(a__					)
                  model.train()

                  SCREAMING_SNAKE_CASE__			:				List[str]       						= self._prepare_for_class(a__ ,  a__ ,  return_labels=a__					)

                  if problem_type["num_labels"] > 1:
                     SCREAMING_SNAKE_CASE__			:				List[str]       						= inputs['''labels'''].unsqueeze(1					).repeat(1 ,  problem_type['''num_labels''']					)

                  SCREAMING_SNAKE_CASE__			:				Dict       						= inputs['''labels'''].to(problem_type['''dtype''']					)

                  # This tests that we do not trigger the warning form PyTorch "Using a target size that is different
                  # to the input size. This will likely lead to incorrect results due to broadcasting. Please ensure
                  # they have the same size." which is a symptom something in wrong for the regression problem.
                  # See https://github.com/huggingface/transformers/issues/11780
                  with warnings.catch_warnings(record=a__					) as warning_list:
                     SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= model(**a__					).loss
                  for w in warning_list:
                     if "Using a target size that is different to the input size" in str(w.message					):
                        raise ValueError(
                            f"""Something is going wrong in the regression problem: intercepted {w.message}"""					)

                  loss.backward()






      @slow
      def    A__(self					)       ->   Any:
         for model_name in EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            SCREAMING_SNAKE_CASE__			:				Tuple       						= EfficientFormerModel.from_pretrained(a__					)
            self.assertIsNotNone(a__					)






      def    A__(self					)       ->   Optional[int]:
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.model_tester.prepare_config_and_inputs_for_common()
         SCREAMING_SNAKE_CASE__			:				Dict       						= True

         SCREAMING_SNAKE_CASE__			:				List[Any]       						= getattr(self.model_tester ,  '''seq_length''' ,  a__					)
         SCREAMING_SNAKE_CASE__			:				Any       						= getattr(self.model_tester ,  '''encoder_seq_length''' ,  a__					)
         SCREAMING_SNAKE_CASE__			:				Dict       						= getattr(self.model_tester ,  '''key_length''' ,  a__					)
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= getattr(self.model_tester ,  '''chunk_length''' ,  a__					)

         if chunk_length is not None and hasattr(self.model_tester ,  '''num_hashes'''					):
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= encoder_seq_length * self.model_tester.num_hashes

         for model_class in self.all_model_classes:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= True
            SCREAMING_SNAKE_CASE__			:				List[str]       						= False
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= True
            SCREAMING_SNAKE_CASE__			:				Any       						= model_class(a__					)
            model.to(a__					)
            model.eval()
            with torch.no_grad():
               SCREAMING_SNAKE_CASE__			:				str       						= model(**self._prepare_for_class(a__ ,  a__					)					)
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
            self.assertEqual(len(a__					) ,  self.model_tester.num_attention_outputs					)

            # check that output_attentions also work using config
            del inputs_dict["output_attentions"]
            SCREAMING_SNAKE_CASE__			:				Any       						= True
            SCREAMING_SNAKE_CASE__			:				Tuple       						= model_class(a__					)
            model.to(a__					)
            model.eval()
            with torch.no_grad():
               SCREAMING_SNAKE_CASE__			:				int       						= model(**self._prepare_for_class(a__ ,  a__					)					)
            SCREAMING_SNAKE_CASE__			:				Any       						= outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
            self.assertEqual(len(a__					) ,  self.model_tester.num_attention_outputs					)

            if chunk_length is not None:
               self.assertListEqual(
                   list(attentions[0].shape[-4:]					) ,  [self.model_tester.num_attention_heads, encoder_seq_length, chunk_length, encoder_key_length] ,  )
            else:
               self.assertListEqual(
                   list(attentions[0].shape[-3:]					) ,  [self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length] ,  )


def 				UpperCamelCase	(  ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__			:				Dict       						= Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''   )
   return image






@require_torch
@require_vision
class 						lowercase     (   unittest.TestCase):






      @cached_property
      def    A__(self					)       ->   int:
         return (
             EfficientFormerImageProcessor.from_pretrained('''snap-research/efficientformer-l1-300'''					)
             if is_vision_available()
             else None
         )






      @slow
      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				str       						= EfficientFormerForImageClassification.from_pretrained('''snap-research/efficientformer-l1-300'''					).to(
             a__					)

         SCREAMING_SNAKE_CASE__			:				Tuple       						= self.default_image_processor
         SCREAMING_SNAKE_CASE__			:				str       						= prepare_img()
         SCREAMING_SNAKE_CASE__			:				str       						= image_processor(images=a__ ,  return_tensors='''pt'''					).to(a__					)

         # forward pass
         with torch.no_grad():
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= model(**a__					)

         # verify the logits
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= (1, 1_0_0_0)
         self.assertEqual(outputs.logits.shape ,  a__					)

         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= torch.tensor([-0.05_55, 0.48_25, -0.08_52]					).to(a__					)
         self.assertTrue(torch.allclose(outputs.logits[0][:3] ,  a__ ,  atol=1E-4					)					)






      @slow
      def    A__(self					)       ->   List[Any]:
         SCREAMING_SNAKE_CASE__			:				Dict       						= EfficientFormerForImageClassificationWithTeacher.from_pretrained(
             '''snap-research/efficientformer-l1-300'''					).to(a__					)

         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.default_image_processor
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= prepare_img()
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= image_processor(images=a__ ,  return_tensors='''pt'''					).to(a__					)

         # forward pass
         with torch.no_grad():
            SCREAMING_SNAKE_CASE__			:				Tuple       						= model(**a__					)

         # verify the logits
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= (1, 1_0_0_0)
         self.assertEqual(outputs.logits.shape ,  a__					)

         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= torch.tensor([-0.13_12, 0.43_53, -1.04_99]					).to(a__					)
         self.assertTrue(torch.allclose(outputs.logits[0][:3] ,  a__ ,  atol=1E-4					)					)







'''simple docstring'''





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_splinter import SplinterTokenizer


lowercase__			=	logging.get_logger(__name__)

lowercase__			=	{'''vocab_file''': '''vocab.txt'''}

lowercase__			=	{
    '''vocab_file''': {
        '''tau/splinter-base''': '''https://huggingface.co/tau/splinter-base/resolve/main/vocab.txt''',
        '''tau/splinter-base-qass''': '''https://huggingface.co/tau/splinter-base-qass/resolve/main/vocab.txt''',
        '''tau/splinter-large''': '''https://huggingface.co/tau/splinter-large/resolve/main/vocab.txt''',
        '''tau/splinter-large-qass''': '''https://huggingface.co/tau/splinter-large-qass/resolve/main/vocab.txt''',
    }
}

lowercase__			=	{
    '''tau/splinter-base''': 5_1_2,
    '''tau/splinter-base-qass''': 5_1_2,
    '''tau/splinter-large''': 5_1_2,
    '''tau/splinter-large-qass''': 5_1_2,
}

lowercase__			=	{
    '''tau/splinter-base''': {'''do_lower_case''': False},
    '''tau/splinter-base-qass''': {'''do_lower_case''': False},
    '''tau/splinter-large''': {'''do_lower_case''': False},
    '''tau/splinter-large-qass''': {'''do_lower_case''': False},
}






class 						lowercase     (   UpperCAmelCase_):
      __lowercase 		=  VOCAB_FILES_NAMES
      __lowercase 		=  PRETRAINED_VOCAB_FILES_MAP
      __lowercase 		=  PRETRAINED_INIT_CONFIGURATION
      __lowercase 		=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      __lowercase 		=  SplinterTokenizer






      def __init__(self ,  a__=None ,  a__=None ,  a__=True ,  a__="[UNK]" ,  a__="[SEP]" ,  a__="[PAD]" ,  a__="[CLS]" ,  a__="[MASK]" ,  a__="[QUESTION]" ,  a__=True ,  a__=None ,  **a__ ,  )       ->   Any:
         super().__init__(
             a__ ,  tokenizer_file=a__ ,  do_lower_case=a__ ,  unk_token=a__ ,  sep_token=a__ ,  pad_token=a__ ,  cls_token=a__ ,  mask_token=a__ ,  tokenize_chinese_chars=a__ ,  strip_accents=a__ ,  additional_special_tokens=(question_token,) ,  **a__ ,  )

         SCREAMING_SNAKE_CASE__			:				Tuple       						= json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
         if (
             pre_tok_state.get('''lowercase''' ,  a__					) != do_lower_case
             or pre_tok_state.get('''strip_accents''' ,  a__					) != strip_accents
         ):
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= getattr(a__ ,  pre_tok_state.pop('''type'''					)					)
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= do_lower_case
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= strip_accents
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= pre_tok_class(**a__					)

         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= do_lower_case






      @property
      def    A__(self					)       ->   List[str]:
         return self.convert_tokens_to_ids(self.question_token					)






      def    A__(self ,  a__ ,  a__ = None					)       ->   List[int]:
         if token_ids_a is None:
            return [self.cls_token_id] + token_ids_a + [self.sep_token_id]

         SCREAMING_SNAKE_CASE__			:				Dict       						= [self.cls_token_id]
         SCREAMING_SNAKE_CASE__			:				Tuple       						= [self.sep_token_id]
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= [self.question_token_id] + [self.convert_tokens_to_ids('''.'''					)]
         if self.padding_side == "right":
            # Input is question-then-context
            return cls + token_ids_a + question_suffix + sep + token_ids_a + sep
         else:
            # Input is context-then-question
            return cls + token_ids_a + sep + token_ids_a + question_suffix + sep






      def    A__(self ,  a__ ,  a__ = None					)       ->   List[int]:
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= [self.sep_token_id]
         SCREAMING_SNAKE_CASE__			:				Any       						= [self.cls_token_id]
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= [self.question_token_id] + [self.convert_tokens_to_ids('''.'''					)]
         if token_ids_a is None:
            return len(cls + token_ids_a + sep					) * [0]

         if self.padding_side == "right":
            # Input is question-then-context
            return len(cls + token_ids_a + question_suffix + sep					) * [0] + len(token_ids_a + sep					) * [1]
         else:
            # Input is context-then-question
            return len(cls + token_ids_a + sep					) * [0] + len(token_ids_a + question_suffix + sep					) * [1]






      def    A__(self ,  a__ ,  a__ = None					)       ->   Tuple[str]:
         SCREAMING_SNAKE_CASE__			:				int       						= self._tokenizer.model.save(a__ ,  name=a__					)
         return tuple(a__					)

