code: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  from __future__ import annotations
  
  import unittest
  
  from transformers import MPNetConfig, is_tf_available
  from transformers.testing_utils import require_tf, slow
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_tf_available():
         import tensorflow as tf
  
         from transformers.models.mpnet.modeling_tf_mpnet import (
             TFMPNetForMaskedLM,
             TFMPNetForMultipleChoice,
             TFMPNetForQuestionAnswering,
             TFMPNetForSequenceClassification,
             TFMPNetForTokenClassification,
             TFMPNetModel,
         )
  
  
  
  
  
  
  class 						lowercase     :
  
  
  
  
  
  
        def __init__(self ,  a__ ,  a__=1_3 ,  a__=7 ,  a__=True ,  a__=True ,  a__=False ,  a__=True ,  a__=9_9 ,  a__=6_4 ,  a__=2 ,  a__=4 ,  a__=6_4 ,  a__="gelu" ,  a__=0.1 ,  a__=0.1 ,  a__=5_1_2 ,  a__=1_6 ,  a__=2 ,  a__=0.02 ,  a__=3 ,  a__=4 ,  a__=None ,  )       ->   List[str]:
           SCREAMING_SNAKE_CASE__			:				int       						= parent
           SCREAMING_SNAKE_CASE__			:				Tuple       						= batch_size
           SCREAMING_SNAKE_CASE__			:				Any       						= seq_length
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= is_training
           SCREAMING_SNAKE_CASE__			:				List[str]       						= use_input_mask
           SCREAMING_SNAKE_CASE__			:				Dict       						= use_token_type_ids
           SCREAMING_SNAKE_CASE__			:				Dict       						= use_labels
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= vocab_size
           SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_size
           SCREAMING_SNAKE_CASE__			:				Tuple       						= num_hidden_layers
           SCREAMING_SNAKE_CASE__			:				str       						= num_attention_heads
           SCREAMING_SNAKE_CASE__			:				Any       						= intermediate_size
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= hidden_act
           SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_dropout_prob
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= attention_probs_dropout_prob
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= max_position_embeddings
           SCREAMING_SNAKE_CASE__			:				int       						= type_vocab_size
           SCREAMING_SNAKE_CASE__			:				str       						= type_sequence_label_size
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= initializer_range
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= num_labels
           SCREAMING_SNAKE_CASE__			:				List[str]       						= num_choices
           SCREAMING_SNAKE_CASE__			:				Any       						= scope
  
  
  
  
  
  
        def    A__(self					)       ->   str:
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= ids_tensor([self.batch_size, self.seq_length] ,  self.vocab_size					)
  
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= None
           if self.use_input_mask:
              SCREAMING_SNAKE_CASE__			:				List[str]       						= random_attention_mask([self.batch_size, self.seq_length]					)
  
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= None
           SCREAMING_SNAKE_CASE__			:				int       						= None
           SCREAMING_SNAKE_CASE__			:				Any       						= None
           if self.use_labels:
              SCREAMING_SNAKE_CASE__			:				Dict       						= ids_tensor([self.batch_size] ,  self.type_sequence_label_size					)
              SCREAMING_SNAKE_CASE__			:				Dict       						= ids_tensor([self.batch_size, self.seq_length] ,  self.num_labels					)
              SCREAMING_SNAKE_CASE__			:				List[str]       						= ids_tensor([self.batch_size] ,  self.num_choices					)
  
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= MPNetConfig(
               vocab_size=self.vocab_size ,  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 ,  max_position_embeddings=self.max_position_embeddings ,  initializer_range=self.initializer_range ,  )
           return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels
  
  
  
  
  
  
        def    A__(self ,  a__ ,  a__ ,  a__ ,  a__ ,  a__ ,  a__					)       ->   Any:
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= TFMPNetModel(config=a__					)
           SCREAMING_SNAKE_CASE__			:				int       						= {'''input_ids''': input_ids, '''attention_mask''': input_mask}
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= model(a__					)
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= [input_ids, input_mask]
           SCREAMING_SNAKE_CASE__			:				str       						= 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__ ,  a__ ,  a__ ,  a__					)       ->   Optional[int]:
           SCREAMING_SNAKE_CASE__			:				List[str]       						= TFMPNetForMaskedLM(config=a__					)
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= {'''input_ids''': input_ids, '''attention_mask''': input_mask}
           SCREAMING_SNAKE_CASE__			:				int       						= model(a__					)
           self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.seq_length, self.vocab_size)					)
  
  
  
  
  
  
        def    A__(self ,  a__ ,  a__ ,  a__ ,  a__ ,  a__ ,  a__					)       ->   List[str]:
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= TFMPNetForQuestionAnswering(config=a__					)
           SCREAMING_SNAKE_CASE__			:				Any       						= {
               '''input_ids''': input_ids,
               '''attention_mask''': input_mask,
           }
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= model(a__					)
           self.parent.assertEqual(result.start_logits.shape ,  (self.batch_size, self.seq_length)					)
           self.parent.assertEqual(result.end_logits.shape ,  (self.batch_size, self.seq_length)					)
  
  
  
  
  
  
        def    A__(self ,  a__ ,  a__ ,  a__ ,  a__ ,  a__ ,  a__					)       ->   Any:
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.num_labels
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= TFMPNetForSequenceClassification(a__					)
           SCREAMING_SNAKE_CASE__			:				List[str]       						= {'''input_ids''': input_ids, '''attention_mask''': input_mask}
           SCREAMING_SNAKE_CASE__			:				str       						= model(a__					)
           self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.num_labels)					)
  
  
  
  
  
  
        def    A__(self ,  a__ ,  a__ ,  a__ ,  a__ ,  a__ ,  a__					)       ->   Optional[Any]:
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= self.num_choices
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= TFMPNetForMultipleChoice(a__					)
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= tf.tile(tf.expand_dims(a__ ,  1					) ,  (1, self.num_choices, 1)					)
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= tf.tile(tf.expand_dims(a__ ,  1					) ,  (1, self.num_choices, 1)					)
           SCREAMING_SNAKE_CASE__			:				int       						= {
               '''input_ids''': multiple_choice_inputs_ids,
               '''attention_mask''': multiple_choice_input_mask,
           }
           SCREAMING_SNAKE_CASE__			:				Tuple       						= model(a__					)
           self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.num_choices)					)
  
  
  
  
  
  
        def    A__(self ,  a__ ,  a__ ,  a__ ,  a__ ,  a__ ,  a__					)       ->   Optional[Any]:
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.num_labels
           SCREAMING_SNAKE_CASE__			:				Tuple       						= TFMPNetForTokenClassification(a__					)
           SCREAMING_SNAKE_CASE__			:				Tuple       						= {'''input_ids''': input_ids, '''attention_mask''': input_mask}
           SCREAMING_SNAKE_CASE__			:				Tuple       						= model(a__					)
           self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.seq_length, self.num_labels)					)
  
  
  
  
  
  
        def    A__(self					)       ->   Optional[Any]:
           SCREAMING_SNAKE_CASE__			:				Tuple       						= self.prepare_config_and_inputs()
           ((SCREAMING_SNAKE_CASE__)						,				(SCREAMING_SNAKE_CASE__)						,				(SCREAMING_SNAKE_CASE__)						,				(SCREAMING_SNAKE_CASE__)						,				(SCREAMING_SNAKE_CASE__)						,				(SCREAMING_SNAKE_CASE__))			:				Optional[Any]       						= config_and_inputs
           SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= {'''input_ids''': input_ids, '''attention_mask''': input_mask}
           return config, inputs_dict
  
  
  
  
  
  
  @require_tf
  class 						lowercase     (   UpperCAmelCase_				,			UpperCAmelCase_				,			unittest.TestCase):
        __lowercase 		=  (
            (
                TFMPNetForMaskedLM,
                TFMPNetForMultipleChoice,
                TFMPNetForQuestionAnswering,
                TFMPNetForSequenceClassification,
                TFMPNetForTokenClassification,
                TFMPNetModel,
            )
            if is_tf_available()
            else ()
        )
        __lowercase 		=  (
            {
                '''feature-extraction''': TFMPNetModel,
                '''fill-mask''': TFMPNetForMaskedLM,
                '''question-answering''': TFMPNetForQuestionAnswering,
                '''text-classification''': TFMPNetForSequenceClassification,
                '''token-classification''': TFMPNetForTokenClassification,
                '''zero-shot''': TFMPNetForSequenceClassification,
            }
            if is_tf_available()
            else {}
        )
        __lowercase 		=  False
        __lowercase 		=  False
  
  
  
  
  
  
        def    A__(self					)       ->   Optional[Any]:
           SCREAMING_SNAKE_CASE__			:				int       						= TFMPNetModelTester(self					)
           SCREAMING_SNAKE_CASE__			:				List[str]       						= ConfigTester(self ,  config_class=a__ ,  hidden_size=3_7					)
  
  
  
  
  
  
        def    A__(self					)       ->   Optional[Any]:
           self.config_tester.run_common_tests()
  
  
  
  
  
  
        def    A__(self					)       ->   Dict:
           SCREAMING_SNAKE_CASE__			:				str       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_model(*a__					)
  
  
  
  
  
  
        def    A__(self					)       ->   Tuple:
           SCREAMING_SNAKE_CASE__			:				List[str]       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_for_masked_lm(*a__					)
  
  
  
  
  
  
        def    A__(self					)       ->   Any:
           SCREAMING_SNAKE_CASE__			:				str       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_for_question_answering(*a__					)
  
  
  
  
  
  
        def    A__(self					)       ->   Dict:
           SCREAMING_SNAKE_CASE__			:				str       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_for_sequence_classification(*a__					)
  
  
  
  
  
  
        def    A__(self					)       ->   Any:
           SCREAMING_SNAKE_CASE__			:				str       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_for_multiple_choice(*a__					)
  
  
  
  
  
  
        def    A__(self					)       ->   int:
           SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_mpnet_for_token_classification(*a__					)
  
  
  
  
  
  
        @slow
        def    A__(self					)       ->   Optional[int]:
           for model_name in ["microsoft/mpnet-base"]:
              SCREAMING_SNAKE_CASE__			:				Dict       						= TFMPNetModel.from_pretrained(a__					)
              self.assertIsNotNone(a__					)
  
  
  
  
  
  
  @require_tf
  class 						lowercase     (   unittest.TestCase):
  
  
  
  
  
  
        @slow
        def    A__(self					)       ->   List[str]:
           SCREAMING_SNAKE_CASE__			:				str       						= TFMPNetModel.from_pretrained('''microsoft/mpnet-base'''					)
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= tf.constant([[0, 1, 2, 3, 4, 5]]					)
           SCREAMING_SNAKE_CASE__			:				Optional[int]       						= model(a__					)[0]
  
           SCREAMING_SNAKE_CASE__			:				str       						= [1, 6, 7_6_8]
           self.assertEqual(output.shape ,  a__					)
  
           SCREAMING_SNAKE_CASE__			:				List[Any]       						= tf.constant(
               [
                   [
                       [-0.1_06_71_72, 0.08_21_64_73, 0.0_02_45_43],
                       [-0.03_46_58_79, 0.8_35_41_18, -0.03_25_22_88],
                       [-0.06_56_94_76, -0.12_42_41_11, -0.0_49_44_36],
                   ]
               ]					)
           tf.debugging.assert_near(output[:, :3, :3] ,  a__ ,  atol=1E-4					)
  
  
style_context: 
  
  
  
  
  '''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__					)
  
  