





import os
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


_A		:				Tuple									=       logging.get_logger(__name__)
_A		:				int									=       {"vocab_file": "spiece.model"}

_A		:				Tuple									=       {
    "vocab_file": {
        "albert-base-v1": "https://huggingface.co/albert-base-v1/resolve/main/spiece.model",
        "albert-large-v1": "https://huggingface.co/albert-large-v1/resolve/main/spiece.model",
        "albert-xlarge-v1": "https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model",
        "albert-xxlarge-v1": "https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model",
        "albert-base-v2": "https://huggingface.co/albert-base-v2/resolve/main/spiece.model",
        "albert-large-v2": "https://huggingface.co/albert-large-v2/resolve/main/spiece.model",
        "albert-xlarge-v2": "https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model",
        "albert-xxlarge-v2": "https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model",
    }
}

_A		:				Dict									=       {
    "albert-base-v1": 512,
    "albert-large-v1": 512,
    "albert-xlarge-v1": 512,
    "albert-xxlarge-v1": 512,
    "albert-base-v2": 512,
    "albert-large-v2": 512,
    "albert-xlarge-v2": 512,
    "albert-xxlarge-v2": 512,
}

_A		:				Dict									=       "▁"



class        a					(			_lowerCamelCase   ):
     UpperCAmelCase__ :  Dict						      =	VOCAB_FILES_NAMES
     UpperCAmelCase__ :  Optional[int]						      =	PRETRAINED_VOCAB_FILES_MAP
     UpperCAmelCase__ :  Any						      =	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES





     def __init__(    self					:				str    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				str=True    ,	SCREAMING_SNAKE_CASE_					:				List[Any]=True    ,	SCREAMING_SNAKE_CASE_					:				List[Any]=False    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]="[CLS]"    ,	SCREAMING_SNAKE_CASE_					:				str="[SEP]"    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]="<unk>"    ,	SCREAMING_SNAKE_CASE_					:				Dict="[SEP]"    ,	SCREAMING_SNAKE_CASE_					:				str="<pad>"    ,	SCREAMING_SNAKE_CASE_					:				Dict="[CLS]"    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]="[MASK]"    ,	SCREAMING_SNAKE_CASE_					:				Any = None    ,	**SCREAMING_SNAKE_CASE_					:				str    ,	):
        # Mask token behave like a normal word, i.e. include the space before it and
        # is included in the raw text, there should be a match in a non-normalized sentence.
        __lowerCamelCase:				int     =	(
            AddedToken(A__    ,	lstrip=A__    ,	rstrip=A__    ,	normalized=A__							)
            if isinstance(A__    ,	A__							)
            else mask_token
        )

        __lowerCamelCase:				int     =	{} if sp_model_kwargs is None else sp_model_kwargs

        super().__init__(
            do_lower_case=A__    ,	remove_space=A__    ,	keep_accents=A__    ,	bos_token=A__    ,	eos_token=A__    ,	unk_token=A__    ,	sep_token=A__    ,	pad_token=A__    ,	cls_token=A__    ,	mask_token=A__    ,	sp_model_kwargs=self.sp_model_kwargs    ,	**A__    ,	)

        __lowerCamelCase:				Any     =	do_lower_case
        __lowerCamelCase:				int     =	remove_space
        __lowerCamelCase:				int     =	keep_accents
        __lowerCamelCase:				List[Any]     =	vocab_file

        __lowerCamelCase:				List[Any]     =	spm.SentencePieceProcessor(**self.sp_model_kwargs							)
        self.sp_model.Load(A__							)





     @property
     def  SCREAMING_SNAKE_CASE__       (    self					:				List[Any]							):
        return len(self.sp_model							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Tuple							):
        __lowerCamelCase:				Any     =	{self.convert_ids_to_tokens(A__							): i for i in range(self.vocab_size							)}
        vocab.update(self.added_tokens_encoder							)
        return vocab





     def __getstate__(    self					:				Dict							):
        __lowerCamelCase:				Optional[Any]     =	self.__dict__.copy()
        __lowerCamelCase:				Optional[int]     =	None
        return state





     def __setstate__(    self					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				List[str]							):
        __lowerCamelCase:				Optional[Any]     =	d

        # for backward compatibility
        if not hasattr(self    ,	"""sp_model_kwargs"""							):
           __lowerCamelCase:				int     =	{}

        __lowerCamelCase:				int     =	spm.SentencePieceProcessor(**self.sp_model_kwargs							)
        self.sp_model.Load(self.vocab_file							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				Dict							):
        if self.remove_space:
           __lowerCamelCase:				Tuple     =	""" """.join(inputs.strip().split()							)
        else:
           __lowerCamelCase:				Dict     =	inputs
        __lowerCamelCase:				Optional[Any]     =	outputs.replace("""``"""    ,	"""\""""							).replace("""''"""    ,	"""\""""							)

        if not self.keep_accents:
           __lowerCamelCase:				str     =	unicodedata.normalize("""NFKD"""    ,	A__							)
           __lowerCamelCase:				Optional[int]     =	"""""".join([c for c in outputs if not unicodedata.combining(A__							)]							)
        if self.do_lower_case:
           __lowerCamelCase:				int     =	outputs.lower()

        return outputs





     def  SCREAMING_SNAKE_CASE__       (    self					:				str    ,	SCREAMING_SNAKE_CASE_					:				int							):
        __lowerCamelCase:				List[Any]     =	self.preprocess_text(A__							)
        __lowerCamelCase:				Union[str, Any]     =	self.sp_model.encode(A__    ,	out_type=A__							)
        __lowerCamelCase:				List[str]     =	[]
        for piece in pieces:
           if len(A__							) > 1 and piece[-1] == str(""","""							) and piece[-2].isdigit():
              __lowerCamelCase:				str     =	self.sp_model.EncodeAsPieces(piece[:-1].replace(A__    ,	""""""							)							)
              if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
                 if len(cur_pieces[0]							) == 1:
                    __lowerCamelCase:				Optional[int]     =	cur_pieces[1:]
                 else:
                    __lowerCamelCase:				Dict     =	cur_pieces[0][1:]
              cur_pieces.append(piece[-1]							)
              new_pieces.extend(A__							)
           else:
              new_pieces.append(A__							)

        return new_pieces





     def  SCREAMING_SNAKE_CASE__       (    self					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				str							):
        return self.sp_model.PieceToId(A__							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]							):
        return self.sp_model.IdToPiece(A__							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]							):
        __lowerCamelCase:				List[Any]     =	[]
        __lowerCamelCase:				List[Any]     =	""""""
        __lowerCamelCase:				List[str]     =	False
        for token in tokens:
           # make sure that special tokens are not decoded using sentencepiece model
           if token in self.all_special_tokens:
              if not prev_is_special:
                 out_string += " "
              out_string += self.sp_model.decode(A__							) + token
              __lowerCamelCase:				List[Any]     =	True
              __lowerCamelCase:				Any     =	[]
           else:
              current_sub_tokens.append(A__							)
              __lowerCamelCase:				int     =	False
        out_string += self.sp_model.decode(A__							)
        return out_string.strip()





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Tuple    ,	SCREAMING_SNAKE_CASE_					:				List[str] = None							):
        __lowerCamelCase:				List[Any]     =	[self.sep_token_id]
        __lowerCamelCase:				List[str]     =	[self.cls_token_id]
        if token_ids_a is None:
           return cls + token_ids_a + sep
        return cls + token_ids_a + sep + token_ids_a + sep





     def  SCREAMING_SNAKE_CASE__       (    self					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				List[Any] = None    ,	SCREAMING_SNAKE_CASE_					:				str = False							):

        if already_has_special_tokens:
           return super().get_special_tokens_mask(
               token_ids_a=A__    ,	token_ids_a=A__    ,	already_has_special_tokens=A__							)

        if token_ids_a is not None:
           return [1] + ([0] * len(A__							)) + [1] + ([0] * len(A__							)) + [1]
        return [1] + ([0] * len(A__							)) + [1]





     def  SCREAMING_SNAKE_CASE__       (    self					:				Union[str, Any]    ,	SCREAMING_SNAKE_CASE_					:				List[Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any] = None							):
        __lowerCamelCase:				Optional[Any]     =	[self.sep_token_id]
        __lowerCamelCase:				List[str]     =	[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  SCREAMING_SNAKE_CASE__       (    self					:				Optional[Any]    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				int = None							):
        if not os.path.isdir(A__							):
           logger.error(F'Vocabulary path ({save_directory}) should be a directory'							)
           return
        __lowerCamelCase:				int     =	os.path.join(
            A__    ,	(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]							)

        if os.path.abspath(self.vocab_file							) != os.path.abspath(A__							) and os.path.isfile(self.vocab_file							):
           copyfile(self.vocab_file    ,	A__							)
        elif not os.path.isfile(self.vocab_file							):
           with open(A__    ,	"""wb"""							) as fi:
              __lowerCamelCase:				Tuple     =	self.sp_model.serialized_model_proto()
              fi.write(A__							)

        return (out_vocab_file,)






from __future__ import annotations

import unittest

from transformers import DistilBertConfig, 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.distilbert.modeling_tf_distilbert import (
       TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
       TFDistilBertForMaskedLM,
       TFDistilBertForMultipleChoice,
       TFDistilBertForQuestionAnswering,
       TFDistilBertForSequenceClassification,
       TFDistilBertForTokenClassification,
       TFDistilBertModel,
   )



class        a					:





     def __init__(    self					:				List[Any]    ,	SCREAMING_SNAKE_CASE_					:				str    ,	):
        __lowerCamelCase:				Optional[int]     =	parent
        __lowerCamelCase:				Dict     =	13
        __lowerCamelCase:				List[Any]     =	7
        __lowerCamelCase:				Optional[int]     =	True
        __lowerCamelCase:				str     =	True
        __lowerCamelCase:				Dict     =	False
        __lowerCamelCase:				Union[str, Any]     =	True
        __lowerCamelCase:				Any     =	99
        __lowerCamelCase:				Dict     =	32
        __lowerCamelCase:				str     =	2
        __lowerCamelCase:				Optional[int]     =	4
        __lowerCamelCase:				Optional[Any]     =	37
        __lowerCamelCase:				Union[str, Any]     =	"""gelu"""
        __lowerCamelCase:				List[Any]     =	0.1
        __lowerCamelCase:				Dict     =	0.1
        __lowerCamelCase:				str     =	512
        __lowerCamelCase:				Dict     =	16
        __lowerCamelCase:				List[str]     =	2
        __lowerCamelCase:				Optional[int]     =	0.02
        __lowerCamelCase:				Dict     =	3
        __lowerCamelCase:				Optional[int]     =	4
        __lowerCamelCase:				Tuple     =	None





     def  SCREAMING_SNAKE_CASE__       (    self					:				int							):
        __lowerCamelCase:				int     =	ids_tensor([self.batch_size, self.seq_length]    ,	self.vocab_size							)

        __lowerCamelCase:				Any     =	None
        if self.use_input_mask:
           __lowerCamelCase:				Optional[int]     =	random_attention_mask([self.batch_size, self.seq_length]							)

        __lowerCamelCase:				Optional[Any]     =	None
        __lowerCamelCase:				Optional[Any]     =	None
        __lowerCamelCase:				List[str]     =	None
        if self.use_labels:
           __lowerCamelCase:				Any     =	ids_tensor([self.batch_size]    ,	self.type_sequence_label_size							)
           __lowerCamelCase:				List[Any]     =	ids_tensor([self.batch_size, self.seq_length]    ,	self.num_labels							)
           __lowerCamelCase:				Optional[int]     =	ids_tensor([self.batch_size]    ,	self.num_choices							)

        __lowerCamelCase:				Any     =	DistilBertConfig(
            vocab_size=self.vocab_size    ,	dim=self.hidden_size    ,	n_layers=self.num_hidden_layers    ,	n_heads=self.num_attention_heads    ,	hidden_dim=self.intermediate_size    ,	hidden_act=self.hidden_act    ,	dropout=self.hidden_dropout_prob    ,	attention_dropout=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  SCREAMING_SNAKE_CASE__       (    self					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Tuple    ,	SCREAMING_SNAKE_CASE_					:				List[Any]    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				List[str]							):
        __lowerCamelCase:				str     =	TFDistilBertModel(config=SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				List[Any]     =	{"""input_ids""": input_ids, """attention_mask""": input_mask}

        __lowerCamelCase:				Optional[Any]     =	model(SCREAMING_SNAKE_CASE_							)

        __lowerCamelCase:				int     =	[input_ids, input_mask]

        __lowerCamelCase:				str     =	model(SCREAMING_SNAKE_CASE_							)

        self.parent.assertEqual(result.last_hidden_state.shape    ,	(self.batch_size, self.seq_length, self.hidden_size)							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Union[str, Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				str    ,	SCREAMING_SNAKE_CASE_					:				List[Any]    ,	SCREAMING_SNAKE_CASE_					:				Dict							):
        __lowerCamelCase:				Any     =	TFDistilBertForMaskedLM(config=SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				Dict     =	{"""input_ids""": input_ids, """attention_mask""": input_mask}
        __lowerCamelCase:				str     =	model(SCREAMING_SNAKE_CASE_							)
        self.parent.assertEqual(result.logits.shape    ,	(self.batch_size, self.seq_length, self.vocab_size)							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]    ,	SCREAMING_SNAKE_CASE_					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				Tuple    ,	SCREAMING_SNAKE_CASE_					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]							):
        __lowerCamelCase:				Optional[int]     =	TFDistilBertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				Tuple     =	{
            """input_ids""": input_ids,
            """attention_mask""": input_mask,
        }
        __lowerCamelCase:				Tuple     =	model(SCREAMING_SNAKE_CASE_							)
        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  SCREAMING_SNAKE_CASE__       (    self					:				Union[str, Any]    ,	SCREAMING_SNAKE_CASE_					:				Union[str, Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]    ,	SCREAMING_SNAKE_CASE_					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]							):
        __lowerCamelCase:				Any     =	self.num_labels
        __lowerCamelCase:				Optional[Any]     =	TFDistilBertForSequenceClassification(SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				Dict     =	{"""input_ids""": input_ids, """attention_mask""": input_mask}
        __lowerCamelCase:				Optional[int]     =	model(SCREAMING_SNAKE_CASE_							)
        self.parent.assertEqual(result.logits.shape    ,	(self.batch_size, self.num_labels)							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				int    ,	SCREAMING_SNAKE_CASE_					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				int    ,	SCREAMING_SNAKE_CASE_					:				Dict							):
        __lowerCamelCase:				Tuple     =	self.num_choices
        __lowerCamelCase:				Optional[int]     =	TFDistilBertForMultipleChoice(SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				Optional[Any]     =	tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_    ,	1							)    ,	(1, self.num_choices, 1)							)
        __lowerCamelCase:				str     =	tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_    ,	1							)    ,	(1, self.num_choices, 1)							)
        __lowerCamelCase:				List[Any]     =	{
            """input_ids""": multiple_choice_inputs_ids,
            """attention_mask""": multiple_choice_input_mask,
        }
        __lowerCamelCase:				int     =	model(SCREAMING_SNAKE_CASE_							)
        self.parent.assertEqual(result.logits.shape    ,	(self.batch_size, self.num_choices)							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Dict    ,	SCREAMING_SNAKE_CASE_					:				Union[str, Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[Any]    ,	SCREAMING_SNAKE_CASE_					:				Optional[int]    ,	SCREAMING_SNAKE_CASE_					:				List[str]    ,	SCREAMING_SNAKE_CASE_					:				Any    ,	SCREAMING_SNAKE_CASE_					:				Union[str, Any]							):
        __lowerCamelCase:				Union[str, Any]     =	self.num_labels
        __lowerCamelCase:				Optional[int]     =	TFDistilBertForTokenClassification(SCREAMING_SNAKE_CASE_							)
        __lowerCamelCase:				Optional[Any]     =	{"""input_ids""": input_ids, """attention_mask""": input_mask}
        __lowerCamelCase:				str     =	model(SCREAMING_SNAKE_CASE_							)
        self.parent.assertEqual(result.logits.shape    ,	(self.batch_size, self.seq_length, self.num_labels)							)







     def  SCREAMING_SNAKE_CASE__       (    self					:				Tuple							):
        __lowerCamelCase:				Dict     =	self.prepare_config_and_inputs()
        ((__lowerCamelCase)   ,     (__lowerCamelCase)   ,     (__lowerCamelCase)   ,     (__lowerCamelCase)   ,     (__lowerCamelCase)   ,     (__lowerCamelCase)):				Tuple     =	config_and_inputs
        __lowerCamelCase:				Dict     =	{"""input_ids""": input_ids, """attention_mask""": input_mask}
        return config, inputs_dict



@require_tf
class        a					(			_UpperCAmelCase     ,_UpperCAmelCase     ,unittest.TestCase   ):
     UpperCAmelCase__ :  Any						      =	(
         (
             TFDistilBertModel,
             TFDistilBertForMaskedLM,
             TFDistilBertForQuestionAnswering,
             TFDistilBertForSequenceClassification,
             TFDistilBertForTokenClassification,
             TFDistilBertForMultipleChoice,
         )
         if is_tf_available()
         else None
     )
     UpperCAmelCase__ :  Dict						      =	(
         {
             "feature-extraction": TFDistilBertModel,
             "fill-mask": TFDistilBertForMaskedLM,
             "question-answering": TFDistilBertForQuestionAnswering,
             "text-classification": TFDistilBertForSequenceClassification,
             "token-classification": TFDistilBertForTokenClassification,
             "zero-shot": TFDistilBertForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     UpperCAmelCase__ :  Optional[Any]						      =	False
     UpperCAmelCase__ :  Tuple						      =	False





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]							):
        __lowerCamelCase:				List[str]     =	TFDistilBertModelTester(self							)
        __lowerCamelCase:				Union[str, Any]     =	ConfigTester(self    ,	config_class=SCREAMING_SNAKE_CASE_    ,	dim=37							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[int]							):
        self.config_tester.run_common_tests()





     def  SCREAMING_SNAKE_CASE__       (    self					:				Union[str, Any]							):
        __lowerCamelCase:				Dict     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_model(*SCREAMING_SNAKE_CASE_							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				int							):
        __lowerCamelCase:				List[Any]     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_masked_lm(*SCREAMING_SNAKE_CASE_							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				List[Any]							):
        __lowerCamelCase:				Tuple     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_question_answering(*SCREAMING_SNAKE_CASE_							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				List[str]							):
        __lowerCamelCase:				List[Any]     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_sequence_classification(*SCREAMING_SNAKE_CASE_							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				Optional[Any]							):
        __lowerCamelCase:				List[Any]     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_multiple_choice(*SCREAMING_SNAKE_CASE_							)





     def  SCREAMING_SNAKE_CASE__       (    self					:				str							):
        __lowerCamelCase:				int     =	self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_token_classification(*SCREAMING_SNAKE_CASE_							)







     @slow
     def  SCREAMING_SNAKE_CASE__       (    self					:				int							):
        for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]							):
           __lowerCamelCase:				List[str]     =	TFDistilBertModel.from_pretrained(SCREAMING_SNAKE_CASE_							)
           self.assertIsNotNone(SCREAMING_SNAKE_CASE_							)



@require_tf
class        a					(			unittest.TestCase   ):





     @slow
     def  SCREAMING_SNAKE_CASE__       (    self					:				List[Any]							):
        __lowerCamelCase:				int     =	TFDistilBertModel.from_pretrained("""distilbert-base-uncased"""							)
        __lowerCamelCase:				Optional[Any]     =	tf.constant([[0, 1, 2, 3, 4, 5]]							)
        __lowerCamelCase:				Any     =	model(SCREAMING_SNAKE_CASE_							)[0]

        __lowerCamelCase:				Union[str, Any]     =	[1, 6, 768]
        self.assertEqual(output.shape    ,	SCREAMING_SNAKE_CASE_							)

        __lowerCamelCase:				List[Any]     =	tf.constant(
            [
                [
                    [0.1926_1885, -0.1373_2955, 0.411_9799],
                    [0.2215_0156, -0.0742_2661, 0.3903_7204],
                    [0.2275_6018, -0.089_6414, 0.370_1467],
                ]
            ]							)
        tf.debugging.assert_near(output[:, :3, :3]    ,	SCREAMING_SNAKE_CASE_    ,	atol=1E-4							)


